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

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

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

1.建立Recordset對(duì)象

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

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

注意:Recordset對(duì)象不能用Set objMyRst=Connection.Excute strSQL的語(yǔ)句建立,因?yàn)槠浣⒌腞ecordset對(duì)象為adOpenFowardOnly不支持記錄集分頁(yè)
2.打開Recordset對(duì)象
復(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對(duì)象的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>")

說(shuō)明:
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對(duì)象
'定義孌數(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對(duì)象
'定義孌數(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
%>

相關(guān)文章

最新評(píng)論