欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP Recordset 分頁顯示數(shù)據(jù)的方法(修正版)

 更新時間:2008年11月07日 17:10:35   作者:  
最近給別人培訓asp 分頁,對于asp的入門新手來說,最簡單的分頁就是用Recordset 分頁技術了,他主要用于一些少量數(shù)據(jù)的分頁,對于新手學習是最好的了,對于大量數(shù)據(jù)分頁不建議用。

1.建立Recordset對象

復制代碼 代碼如下:

Dim objMyRst
Set objMyRst=Server.CreateObject(“ADODB.Recordset”)
objMyRst.CursorLocation=adUseClientBatch ‘客戶端可批量處理
objMyRst.CursorType=adOpenStatic'光標類型為靜態(tài)類型

注意: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屬性
以下為引用的內(nèi)容:
復制代碼 代碼如下:

Dim intCurrentPage
intCurrentPage=1
objMyRst.AbsolutePage=intCurrentPage

AbsolutePage為1到Recordset對象的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定義的常量,要使用的話要把adovbs.inc拷到當前目錄中并包含于在程序中
復制代碼 代碼如下:

<!--#Include File=”adovbs.inc”-->

2. PrintFielName,PrintFieldValue函數(shù)的代碼如下:
復制代碼 代碼如下:

<%
Function PrintFieldName(objMyRst)
'參數(shù)objMyRst是Recordset對象
'定義孌數(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對象
'定義孌數(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
%>

相關文章

最新評論