1. Creating a Recordset object
Dim Objmyrst
Set objmyrst=server.createobject ("ADODB. Recordset ")
Objmyrst.cursorlocation=aduseclientbatch ' client can be processed in batches
Objmyrst.cursortype=adopenstatic ' cursor type is static type
Note: The Recordset object cannot be established with a set Objmyrst=connection.excute strSQL statement because the Recordset object it creates is adopenfowardonly does not support recordsets paging
2. Open a Recordset object
Dim strSql
strSql=”select * from ietable”
objMyRst.Oepn strSql,ActiveConnection,,,adCmdText
3. Set the PageSize property of a recordset
Objmyrst.pagesize=20
The default pagesize is 10
4. Set the AbsolutePage property of a recordset
Dim Intcurrentpage
Intcurrentpage=1
Objmyrst.absolutepage=intcurrentpage
AbsolutePage is a PageCount value of 1 to the Recordset object
5. Display data
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>")
Description
1. Adopenstatic,adusecilentbatch,adcmdtext for Adovbs.inc defined constants, to use the words to copy Adovbs.inc to the current directory and included in the program
<!--#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
%>