<%
if Request.QueryString("PageNumber").count > 0 then
' 指定页号的参数PageNumber.如果指定页号,则以指定页号为依据.
PageNumber = Request.QueryString("PageNumber")(1)
else
PageNumber = 1
' 如没指定页号,缺省为1.
end if
RecordNumberPerPage = 10
' 每页显示10条记录.
set ARecordSet = Server.CreateObject("ADODB.RecordSet")
ARecordSet.open "select * from contact1",AConnection,1
' 执行查询,注意Open语句中指定的第三个参数.
ARecordSet.PageSize = RecordNumberPerPage
' 指定每页记录条数.
ARecordSet.AbsolutePage = PageNumber
' 指定当前页号.
Response.Write "<br>每页有"&ARecordSet.PageSize&"条记录"
Response.Write "<br>共有"&ARecordSet.PageCount&"页"
Response.Write "<br>这是第"&PageNumber&"页"
Response.Write "<Table border=1>"
' 以表格形式显示查询结果.
Response.Write "<tr>"
For FieldNo = 0 to ARecordSet.Fields.count - 1
Response.Write "<td>"&ARecordSet( FieldNo ).Name&"</td>"
Next
Response.Write "</tr>"
' 显示字段名.
RecordCounter = 0
Do while not ARecordSet.eof
RecordCounter = RecordCounter + 1
' 显示查询.
if RecordCounter > RecordNumberPerPage then
' 如果要显示的记录数大于每页记录数目,则停止显示.
Exit do
end if
Response.Write "<tr>"
For FieldNo = 0 to ARecordSet.Fields.count - 1
Response.Write "<td>"&ARecordSet( FieldNo )&"</td>"
Next
Response.Write "</tr>"
' 显示一条记录.
ARecordSet.MoveNext
Loop
' 转向下一条记录.
Response.Write "</Table>"
if PageNumber > 1 then
' 如果不是第一页,则提示上一页.
Response.Write "<p><A href = chunfeng.asp?PageNumber="&(PageNumber-1)&">[上一页]</a>"
[1] [2] 下一页