本文为【ASP分页显示Recordset数据】的汉字拼音对照版显示拼音
1.建jian立liRecordset对dui象xiang
Dim objMyRst
Set objMyRst=Server.CreateObject(“ADODB.Recordset”)
objMyRst.CursorLocation=adUseClientBatch ‘客ke户hu端duan可ke批pi量liang处chu理li
objMyRst.CursorType=adOpenStatic’光guang标biao类lei型xing为wei静jing态tai类lei型xing
注zhu意yi:Recordset对dui象xiang不bu能neng用yongSet objMyRst=Connection.Excute strSQL的de语yu句ju建jian立li,因yin为wei其qi建jian立li的deRecordset对dui象xiang为weiadOpenFowardOnly不bu支zhi持chi记ji录lu集ji分fen页ye
2.打da开kaiRecordset对dui象xiang
Dim strSql
strSql=”select * from ietable”
objMyRst.Oepn strSql,ActiveConnection,,,adCmdText
3.设she置zhiRecordset的dePageSize属shu性xing
objMyRst.PageSize=20
默mo认ren的dePageSize为wei10
4.设she置zhiRecordset的deAbsolutePage属shu性xing
Dim intCurrentPage
intCurrentPage=1
objMyRst.AbsolutePage=intCurrentPage
AbsolutePage为wei1到daoRecordset对dui象xiang的dePageCount值zhi
5.显xian示shi数shu据ju
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>")
说shuo明ming:
1. adOpenStatic,adUseCilentBatch,adCmdText为weiadovbs.inc定ding义yi的de常chang量liang,要yao使shi用yong的de话hua要yao把baadovbs.inc拷kao到dao当dang前qian目mu录lu中zhong并bing包bao含han于yu在zai程cheng序xu中zhong
<!--#Include File=”adovbs.inc”-->
2. PrintFielName,PrintFieldValue函han数shu的de代dai码ma如ru下xia:
<%
Function PrintFieldName(objMyRst)
'参shen数shuobjMyRst是shiRecordset对dui象xiang
'定ding义yi娈luan数shu
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)
'参shen数shuobjMyRst是shiRecordset对dui象xiang
'定ding义yi娈luan数shu
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
%>
【原文】