How do I page out the results of a database query? _ Programming 10000 Q

Source: Internet
Author: User

<%
If Request.QueryString ("PageNumber"). Count > 0 Then

' Specifies the parameter pagenumber of the page number . If the page number is specified , the specified page number is the basis .

PageNumber = Request.QueryString ("PageNumber") (1)
Else
PageNumber = 1

no page number specified Span lang= "en-US" >, defaults to 1.
End If

Recordnumberperpage = ten

' every page shows Span lang= "en-US" >10 record
 set arecordset = Server.CreateObject ("ADODB. RecordSet ")
Arecordset.open" SELECT * from Contact1 ", aconnection,1
" Execute query , note open
Arecordset.pagesize = recordnumberperpage

' specifies the number of record bars per page .
Arecordset.absolutepage = pagenumber

'Specify the current page number.

Response.Write "<br>Each page has"&ARecordSet.PageSize&"Records"
Response.Write "<br>Total"&ARecordSet.PageCount&"Page"
Response.Write "<br> This is " &PageNumber& " Span Times New Roman '; Mso-hansi-font-family: ' Times Roman ' "> page
Response.Write" <table border=1> "
" Span Times New Roman '; Mso-hansi-font-family: ' Times Roman ' "The query results are displayed in tabular form
Response.Write "<tr>"
for fieldno = 0 to Arecordset.fields.count-1
Response.Write "<td>" & Arecordset (Fieldno). name& "</td>"
Next
Response.Write "</tr>"
' display field name
Recordcounter = 0
Do While not arecordset.eof
Recordcounter = recordcounter + 1
' show query
If Recordcounter > recordnumberperpage then

' if the number of records to display is greater than the number of records per page , stop the display .
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>"

' displays a record .

Arecordset.movenext
Loop
' turn to the next record .

Response.Write "</Table>"

If pagenumber > 1 Then

' if it is not the first page, the previous page is prompted .
Response.Write "<p><a href = chunfeng.asp?" Pagenumber= "& (PageNumber-1) &" >[prev ]</a> "

[1] [2] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.