Ado|web Example one: pagination display and navigation:
Why do I have to mention the paging question again? Because this is a basic problem, although there are many articles on pagination, but I think their approach is more complex. In fact, the recordset's AbsolutePage can easily implement pagination, when you specify the PageSize property, the AbsolutePage specified value can be flipped to the specified page. But if you want to use AbsolutePage, you must set its CursorLocation value to adUseClient before opening the Recordset object, which is a property that inherits the connection object. You can also set it before you open the Connection object. The following is the source code, in order to facilitate, I will be independent of the navigation bar into a subroutine to facilitate the use of everyone.
<%
Sub Navigator (pageno,target)
Response.Write "<table border=0>"
Response.Write "<tr>"
Response.Write "<td>"
If Pageno>1 Then
Response.Write "<a href=" &CHR (&Target&)? Page=1 "&CHR" & ">┃ first page </a>"
Else
Response.Write "┃ first page"
End If
Response.Write "</td>"
Response.Write "<td>"
If Pageno<rs. PageCount Then
Response.Write "<a href=" &CHR (&Target&)? Page= "&PAGENO+1&CHR &" >┃ next </a> "
Else
Response.Write "┃ next Page"
End If
Response.Write "</td>"
Response.Write "<td>"
If Pageno>1 Then
Response.Write "<a href=" &CHR (&Target&)? Page= "&PAGENO-1&CHR &" >┃ previous </a> "
Else
Response.Write "┃ Previous Page"
End If
Response.Write "</td>"
Response.Write "<td>"
If Pageno<rs. PageCount Then
Response.Write "<a href=" &CHR (&Target&)? Page= "&rs. PAGECOUNT&CHR & ">┃ last page </a>"
Else
Response.Write "┃ last Page"
End If
Response.Write "</td>"
Response.Write "<td>"
Response.Write "┃ page:" &PageNo& "/" &rs. pagecount& "Page ┃" &rs. pagesize& "Record/page ┃"
Response.Write "</td>"
Response.Write "<td valign=" middle ">"
Response.Write "<form action=" &CHR (a) &TARGET&CHR & "method=" &CHR (a) & "POST" & Chr (& ">")
Response.Write "<input type=" text "size=3 maxlength=4 name=" Page ">"
Response.Write "<input type=" submit "value=" Go to ">"
Response.Write "</form>"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "</table>"
End Sub
%>
<%
Const ADCMDTEXT=&H0001
Const ADVARCHAR=200
Const ADINTEGER=3
Const ADPARAMINPUT=&H0001
Const ADCMDTABLE=&H0002
Const ADUSECLIENT=3
Const ADDATE=7
Const ADLONGVARCHAR=201
Set Conn=server.createobject ("ADODB. Connection ")
Conn. connectionstring= "Driver={microsoft Access Driver (*.mdb)};D bq=" & _
Server.MapPath ("/source_asp") & "/process/process.mdb";
Conn. Open
%>
<%
Const MAXPAGESIZE=5
%>
<title> Book </title>
<body>
<%
Dim I,j,pageno
Set Rs=server.createobject ("ADODB. RecordSet ")
Rs. Activeconnection=conn
Rs. Cursorlocation=aduseclient
Rs. Open "SELECT * from books",,, adCmdText
If Rs. BOF Then
Response.Write "Welcome to use the book, Data management program!"
Else
Rs. Pagesize=maxpagesize
If IsEmpty (Request.QueryString ("Page")) Then
Pageno=1
ElseIf cInt (Request.QueryString ("Page")) <1 Then
Pageno=1
ElseIf cInt (Request.QueryString ("Page")) >rs. PageCount Then
Pageno=rs. PageCount
Else
Pageno=cint (Request.QueryString ("Page"))
End If
If Request.ServerVariables ("request_method") = "POST" and Not IsEmpty (Request.Form ("page")) Then
Pageno=cint (Request.Form ("Page"))
End If
Rs. Absolutepage=pageno
Response.Write "<table border=" 0 "width=" 100% ">"
Response.Write "<tr><td colspan=" &rs.fields.count& ">"
target= "Books.asp"
Call Navigator (pageno,target) calls the navigation bar
Response.Write "</td></tr>"
Response.Write "<tr>"
For I=0 to Rs.fields.count-1
Response.Write "<td>" &rs.fields.item (i) .name& "</td>"
Next
Response.Write "</tr>"
J=0
while (not Rs. EO