<%
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] 下一頁