Recently looked at some forums above on the paging of the ASP program still has a lot of attention, but there is only code, there is no detailed explanation, for beginners, this is always not really mastered, this time I will be detailed for paging technology, so that everyone can understand the ASP paging, OK, Come to a thorough understanding of the paging process!
First, look at the effect!
Look at the function: the paging program first reads the number of preset records per page, this is 5, and others will be displayed on the next page, also prompts the current number of pages, total pages, total records, when the first page is displayed, the "Home", "prev" link is invalid, when the number of pages displayed is the last page, the "Next", "last" link is invalid.
Next, let me tell you how to make this paging effect step-by-step in the way of example.
First, the field Record_info in the database exists in the info table (there is a database in the instance download), first linking the database and opening a recordset, the following code:
<%
Set conn=Server.CreateObject("Adodb.Connection")
connstr="provider=Microsoft.JET.OLEDB.4.0;Data Source="&Server.MapPath("data.mdb")
conn.open connstr
Set rs=Server.CreateObject("Adodb.Recordset")
sql="Select * from info"
rs.open sql,conn,1,1
%>
This code is not clear, I believe that the beginning of the city, the specific explanation can see "hands-on teach you to use ASP to do the message this" tutorial,
Then this is the more important part of the page, with three lines:
<%
rs.pagesize=5
curpage=Request.QueryString("curpage")
rs.absolutepage=curpage
%>
Second sentence:
Rs.pagesize=5, what does this mean? It is a built-in property in the Recordset object, its role is to specify the number of records per page, set to 5 o'clock, every 5 records together into a page, for example, there are 21 records in the instance, then, using rs.pagesize pagination, the 21 records will be divided into 5 pages to display.
Third sentence:
This is mainly used for paging function, the URL of the post parameter curpage passed to the curpage variable, this curpage will be the number of pages visitors want to reach. (Run the example and you'll see)