主頁 > 知識庫 > ASP Recordset 分頁顯示數(shù)據(jù)的方法(修正版)

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

熱門標(biāo)簽:Linux服務(wù)器 Mysql連接數(shù)設(shè)置 團(tuán)購網(wǎng)站 銀行業(yè)務(wù) 電子圍欄 科大訊飛語音識別系統(tǒng) 服務(wù)器配置 阿里云

1.建立Recordset對象

復(fù)制代碼 代碼如下:

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

注意:Recordset對象不能用Set objMyRst=Connection.Excute strSQL的語句建立,因為其建立的Recordset對象為adOpenFowardOnly不支持記錄集分頁
2.打開Recordset對象
復(fù)制代碼 代碼如下:

Dim strSql
strSql=”select * from ietable”
objMyRst.Oepn strSql,ActiveConnection,,,adCmdText

3.設(shè)置Recordset的PageSize屬性
復(fù)制代碼 代碼如下:

objMyRst.PageSize=20

默認(rèn)的PageSize為10
4.設(shè)置Recordset的AbsolutePage屬性
以下為引用的內(nèi)容:
復(fù)制代碼 代碼如下:

Dim intCurrentPage
intCurrentPage=1
objMyRst.AbsolutePage=intCurrentPage

AbsolutePage為1到Recordset對象的PageCount值
5.顯示數(shù)據(jù)
復(fù)制代碼 代碼如下:

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)前目錄中并包含于在程序中
復(fù)制代碼 代碼如下:

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

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

%
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
%>

您可能感興趣的文章:
  • 用vbs模擬的一個asp的分頁顯示功能
  • asp長文章用分頁符來分頁顯示
  • asp.net 文章內(nèi)容分頁顯示的代碼
  • asp.net 分頁顯示數(shù)據(jù)表的數(shù)據(jù)的代碼
  • asp.net 通用分頁顯示輔助類(改進(jìn)版)
  • asp.net 文章分頁顯示實現(xiàn)代碼
  • Asp 解析 XML并分頁顯示源碼
  • ASP中實現(xiàn)分頁顯示的七種方法

標(biāo)簽:廣元 萍鄉(xiāng) 江蘇 衢州 衡水 大理 棗莊 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP Recordset 分頁顯示數(shù)據(jù)的方法(修正版)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266