1.建立Recordset對(duì)象
Dim objMyRst
Set objMyRst=Server.CreateObject(“ADODB.Recordset”)
objMyRst.CursorLocation=adUseClientBatch ‘客戶端可批量處理
objMyRst.CursorType=adOpenStatic’光標(biāo)類型為靜態(tài)類型
注意:Recordset對(duì)象不能用Set objMyRst=Connection.Excute strSQL的語句建立,因?yàn)槠浣⒌腞ecordset對(duì)象為adOpenFowardOnly不支持記錄集分頁
2.打開Recordset對(duì)象
Dim strSql
strSql=”select * from ietable”
objMyRst.Oepn strSql,ActiveConnection,,,adCmdText
3.設(shè)置Recordset的PageSize屬性
objMyRst.PageSize=20
默認(rèn)的PageSize為10
4.設(shè)置Recordset的AbsolutePage屬性
Dim intCurrentPage
intCurrentPage=1
objMyRst.AbsolutePage=intCurrentPage
AbsolutePage為1到Recordset對(duì)象的PageCount值
5.顯示數(shù)據(jù)
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定義的常量,要使用的話要把a(bǔ)dovbs.inc拷到當(dāng)前目錄中并包含于在程序中
<!--#Include File=”adovbs.inc”-->
2. PrintFielName,PrintFieldValue函數(shù)的代碼如下:
<%
Function PrintFieldName(objMyRst)
'參數(shù)objMyRst是Recordset對(duì)象
'定義孌數(shù)
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)
'參數(shù)objMyRst是Recordset對(duì)象
'定義孌數(shù)
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
%>
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注