当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP分页显示Recordset数据

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

ASP分页显示Recordset数据


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 94 ::
收藏到网摘: n/a

1.建立Recordset对象

注意: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

4.设置Recordset的AbsolutePage属性

以下为引用的内容:

Dim intCurrentPage

intCurrentPage=1

objMyRst.AbsolutePage=intCurrentPage

AbsolutePage为1到Recordset对象的PageCount值

5.显示数据

以下为引用的内容:

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

%>