Webcomputing━ado Summary Report 7

Source: Internet
Author: User
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=" &AMP;CHR (&Target&)? Page=1 "&AMP;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=" &AMP;CHR (&Target&)? Page= "&AMP;PAGENO+1&AMP;CHR &" >┃ next </a> "
Else
Response.Write "┃ next Page"
End If
Response.Write "</td>"
Response.Write "<td>"
If Pageno>1 Then
Response.Write "<a href=" &AMP;CHR (&Target&)? Page= "&AMP;PAGENO-1&AMP;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=" &AMP;CHR (&Target&)? Page= "&rs. PAGECOUNT&AMP;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=" &AMP;CHR (a) &AMP;TARGET&AMP;CHR & "method=" &AMP;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=&AMP;H0001
Const ADVARCHAR=200
Const ADINTEGER=3
Const ADPARAMINPUT=&AMP;H0001
Const ADCMDTABLE=&AMP;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



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.