Page 1/2 of simple ASP paging code (correct test)

Source: Internet
Author: User

This article has been tested in a hurry and supports ASP + ACCESS and ASP + SQL. Please modify the relevant sections.
Note: The answer to the basic question is declined in a hurry. This code is already very simple. If you still don't understand it, you can refer to other topics on this site.

<! -- # Include file = "conn. asp" -->
<% 'And above are database cohesion files
'-------------------------------------------- Query start Database

Set rs = server. CreateObject ("adodb. recordset ")
Rs. open "select * from books where id =" & id & "order by id desc", conn, 1, 1
If err. number <> 0 then
Response. write "no data in the database"
End if

'------------------------------------------ Start by PAGE
If rs. recordcount = 0 then
Respose. write "no data"
Else
Rs. PageSize = 10' number of records per page
ICount = rs. RecordCount 'total number of records
IPageSize = rs. PageSize
Maxpage = rs. PageCount
Page = request ("page ")

If Not IsNumeric (page) or page = "" then
Page = 1
Else
Page = cint (page)
End if

If page <1 then
Page = 1
Elseif page> maxpage then
Page = maxpage
End if

Rs. AbsolutePage = Page

If page = maxpage then
X = iCount-(maxpage-1) * iPageSize
Else
X = iPageSize
End if

For I = 1 To x

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.