推薦:解析ASP實例:幻燈片新聞代碼以下為引用的內容: !--這是一個主頁文件-->html>head>meta http-equiv=Content-Type content=
1.建立Recordset對象
以下為引用的內容: Dim objMyRst Set objMyRst=Server.CreateObject(“ADODB.Recordset”) objMyRst.CursorLocation=adUseClientBatch ‘客戶端可批量處理 objMyRst.CursorType=adOpenStatic’光標類型為靜態類型 |
注意:Recordset對象不能用Set objMyRst=Connection.Excute strSQL的語句建立,因為其建立的Recordset對象為adOpenFowardOnly不支持記錄集分頁
2.打開Recordset對象
以下為引用的內容: Dim strSql strSql=”select * from ietable” objMyRst.Oepn strSql,ActiveConnection,,,adCmdText 3.設置Recordset的PageSize屬性 objMyRst.PageSize=20 默認的PageSize為10 |
3.設置Recordset的AbsolutePage屬性
以下為引用的內容: Dim intCurrentPage intCurrentPage=1 objMyRst.AbsolutePage=intCurrentPage AbsolutePage為1到Recordset對象的PageCount值 |
4.顯示數據
以下為引用的內容: Response.Write("<table>") PrintFieldName(objMyRst) For i=1 To objMyRst.PageSize PrintFieldValue(objMyRst) objMyRst.MoveNext If objMyRst.Eof Then Exit For Next Response.Write("</table>") |
說明:
1. adOpenStatic,adUseCilentBatch,adCmdText為adovbs.inc定義的常量,要使用的話要把adovbs.inc拷到當前目錄中并包含于在程序中
以下為引用的內容: <!--#Include File=”adovbs.inc”--> 2. PrintFielName,PrintFieldValue函數的代碼如下: <% Function PrintFieldName(objMyRst) '參數objMyRst是Recordset對象 '定義孌數 Dim objFld Response.Write "<tr bgcolor='#CCCCCC'>" For Each objFld In objMyRst.Fields Response.Write "<td>" & objFld.Name & "</td>" Next Response.Write("</tr>") End Function Function PrintFieldValue(objMyRst) '參數objMyRst是Recordset對象 '定義孌數 Dim objFld Response.Write("<tr >") For Each objFld In objMyRst.Fields 'Response.Write "<td>" & objMyRst.Fields(intLoop).value & "</td>" Response.Write "<td>" & objFld.value & "</td>" Next Response.Write("<tr>") End Function %> |
分享:解讀處理多關鍵詞查詢實例代碼在web開發中經常遇到多關鍵詞對對單個字段查詢,我一般是通過動態數組來實現的。當然多個關鍵詞的一般是用空格或,隔開,我這幾假設多個關鍵詞用空格隔開,關鍵字字符串為keyStr,具體代碼為
新聞熱點
疑難解答