最近给别人培训asp 分页,对于asp的入门新手来说,最简单的分页就是用Recordset 分页技术了,他主要用于一些少量数据的分页,对于新手学习是最好的了,对于大量数据分页不建议用。
1.建立Recordset对象
Set objMyRst=Server.CreateObject(“ADODB.Recordset”)
objMyRst.CursorLocation=adUseClientBatch ‘客户端可批量处理
objMyRst.CursorType=adOpenStatic’光标类型为静态类型
注意:Recordset对象不能用Set objMyRst=Connection.Excute strSQL的语句建立,因为其建立的Recordset对象为adOpenFowardOnly不支持记录集分页
2.打开Recordset对象
strSql=”select * from ietable”
objMyRst.Oepn strSql,ActiveConnection,,,adCmdText
3.设置Recordset的PageSize属性
默认的PageSize为10
4.设置Recordset的AbsolutePage属性
以下为引用的内容:
intCurrentPage=1
objMyRst.AbsolutePage=intCurrentPage
AbsolutePage为1到Recordset对象的PageCount值
5.显示数据
“)
说明:
1. adOpenStatic,adUseCilentBatch,adCmdText为adovbs.inc定义的常量,要使用的话要把adovbs.inc拷到当前目录中并包含于在程序中
2. PrintFielName,PrintFieldValue函数的代码如下:
Function PrintFieldName(objMyRst)
‘参数objMyRst是Recordset对象
‘定义娈数
Dim objFld
Response.Write “
For Each objFld In objMyRst.Fields
Response.Write “
”
Next
Response.Write(“
“)
End Function
Function PrintFieldValue(objMyRst)
‘参数objMyRst是Recordset对象
‘定义娈数
Dim objFld
Response.Write(“
For Each objFld In objMyRst.Fields
‘Response.Write “
”
Response.Write “
”
Next
Response.Write(“
End Function
%>
以上就是ASP Recordset 分页显示数据的方法(修正版)的详细内容,更多请关注gaodaima搞代码网其它相关文章!