Paging <%
'******************************************************************
' * * * This program name: "Unlimited Flow" paging program
' * * Author: arbiter (AASX)
' * * Version: Million level
'**
' * * qq:22222xx
' * * email:arbiter@21cn.com
' * * http://www.imagecity.org/
'******************************************************************
'**
' * * * the words of the author
'**
' * * Paging program is undoubtedly a lot of network program features a more troublesome thing, in fact, now
' * * Most people still use the traditional paging method (RS.PAGESIZE=XX) to understand
' * * operators know that this traditional way has a disadvantage: the first time you open the page,
' * * It will read all the recordset, which will be fatal when the data is large, and then
' * * The paging speed will also be very slow, very consuming resources. For data above 100,000 orders of magnitude
' * * Library This traditional way of paging has become very weak, let alone millions
' * *). For this reason, I was prompted to do this procedure.
'**
' * * "program features"
'**
' * * For large paging operations, the ideal operation of the data recorded in the amount of 2 million
' * * within the MAX level version will be unlimited, and no matter how big, the page speed is
' * * unchanged), this is the million level paging program in Celeron 1G, memory 512, Win2K ring
' * * Under the test data:
'**
' * * SQL Server 2k + 100,000 records + 20 per page:
' * * Average page speed: 45ms
' * * SQL Server 2k + 1 million records + 20 per page:
' * * Average page speed: 350ms
'**
'**
' * * "paging principle"
'**
' * * * This program no longer uses the rs.pagesize way of paging, connected cursor types
' * * Also not use conn,1,x, but conn,0,1, this should be the fastest cursor type, do not
' * * thought it would make the program complex, on the contrary, the program is very simple, if you do not understand,
' * * should be my programming style you're not accustomed to, not program complex.
' * * The center of the "Infinite Stream" pagination is: each page reads only the records that need to be displayed, no longer the traditional
' * * Paging program to read all the data, which is the greatest advantage of this program-less resources, with
' * * speed is also greatly improved, especially in the amount of data, its speed advantage
' * * The more obvious (1 million records are only about 350ms).
' * * * When the program is executed, use the Curcorbegin and Curcorend records to display the first note
' * * record and the ID value of the last record, as the next page turn mark, and then take the top xx
' * * Show the required data, and then record the ID value.
'**
' * * * * words
'**
' * * This procedure is a shared version, provided to the program enthusiasts for research and use, to reprint, spread, repair
' * * To change or for other purposes, please respect the author's hard work, indicate the source.
' * * If there are defects in this program, such as errors, not optimization, please go to www.csdn.net Web development/
' * * ASP column in the discussion, for the development of China's software industry, please do not be complacent:
'**
'********************************************************************
Option Explicit
' Response.Flush
Dim Begintime,endtime
Begintime=timer
Dim Conn,sqlstr,rs,defrecordnum,cursorbegin,cursorend,curpagenum,hav
Defrecordnum=20
'--------------get related parameters----------
if request ("cursorbegin") = "" then cursorbegin=0 else cursorbegin=request ("Cursorbegin")
If request ("cursorend") = "" Then CursorEnd=0 Else cursorend=request ("Cursorend")
If request ("Curpagenum") <> " then
curpagenum= CLng (Request ("Curpagenum"))
If curpagenum<=0 then curpagenum=1
Else
Curpagenum=1
End if
hav=request ("hav")
if hav= "" then hav= "Next"
'---------------- End-----------------
The
------------displays the paging content function--------
function turnpagefs (disprecordnum)
Dim n
While not ( rs.eof) and n<disprecordnum
n=n+1
response.write "<tr>" &_
"<td Bgcolor= ' efefef ' > ' &rs (0) & "</td>" &_
"<td bgcolor= ' efefef ' >" &rs (1) & " </td> "&_
" <td bgcolor= ' efefef ' > "&rs (2) &" </td> "&_
" <td Bgcolor= ' efefef ' > ' &rs (3) & "</td>" &_
"<td bgcolor= ' efefef ' >" &rs (4) & " </td> "&_
" <td bgcolor= ' efefef ' > "&rs (5) &" </td> "&_
" </tr> "
If n=1 then cursorbegin=rs (0)
if n=defrecordnum or rs.eof then Cursorend=rs (0)
Rs.movenext
Wend
end function
'-------------connection-------------
Set conn=server.createobject ("Adodb.connection")
' sqlstr= ' Provider=Microsoft.Jet.OLEDB.4.0;Data source= ' &server.mappath ("Mldata.mdb")
Sqlstr= "Driver={sql Server};server=arbiter;uid=arbiter;pwd=123456;database=mldata"
Conn. Open Sqlstr
'---------Total Statistics record/total number of pages---------
'-ps: It is recommended to use COUNT (ID), the ID is AutoNumber and index, otherwise the speed may be greatly compromised
'-ps: This statistic is the most resource-consuming part of this program, and if you cancel this program, it will be about 10 times times faster.
Dim totalrecords,totalpages