The following is the code fragment: '***********************************************************************************************************************************************************************************************************************************************************************, ********************** '** This program name: "Infinite Stream" paging program '** Author: Arbiter (AASX) '** version: Million level '** '** QQ: 22222xx '** email: [email protected] '** http://www.images.org/ '***********************************************************************************************************************************************************************************************************************************************************************, ********************** '** '** [Author's words] '** '** paging program is undoubtedly a more troublesome thing among many network program functions. In fact, now '** Most people still use the traditional paging method (RS.PAGESIZE = XX) to understand '** Database operations know that this traditional method has a disadvantage: when the page is opened for the first time, '** It will read all the record sets. This will be fatal when the data is large, and it will be connected '** pages will also be very slow, occupying resources. For data of more than 100,000 or more '** library this traditional paging method has become very weak, let alone a million levels (I can’t fuck at all '** do). For this reason, I have prompted me to do this program. '** '** [program function] '** '** Pagling operation for large databases, the ideal operating data record volume is 2 million ‘** (Max Level edition will limit countless quantities, and no matter how large the database is, the page turning speed is '** unchanged), this is the paging program of the Million Level version in Saiyang 1G, memory 512, Win2K ring '** Test data in the realm: '** '** SQLServer 2K 100,000 records show 20 pieces per page: '** Average page turning speed: 45ms '** SQLServer 2K 1 million records display 20 pieces per page: '** Average page turning speed: 350ms '** '** '** [Pagling principle] '** '** This program no longer uses the rs.pageSize method to pages, and the cursor type connecting the database '** is not using Conn, 1, X, but CONN, 0,1, which should be the fastest cursor type, don’t '** thinks that this will make the program complicated. On the contrary, the program is very simple. If you don’t understand, '** It should be my programming style. You are not used to it, not the complicated program. The center of the paging of '** "Infinite Stream" is: read only the records that need to be displayed per page, no longer like tradition '** Pagling program reads all the data pre-read, which is the biggest advantage of this program-occupy less resources, the same '** rational speed has also been greatly improved, especially when the amount of data is greater, its speed advantage '** more obvious (only about 350ms). '** When the program is executed, the first record displayed by Curcorbegin and Curcorend '** Record and the ID value of the last record, as the mark of the next page, and then use TOP XX to take '** The data required shows it, and then records the ID value. '** '** [Conclusion] '** '** This program is a shared version, provided to various program lovers to study and use, to reprint, spread, repair '** change or be used for other purposes, please respect the author's hard work and indicate the source. '** If there are disadvantages such as error and optimization in this program, please go to the web development of www.csdn.net/ '** ASP column issued a discussion, for the development of China's software industry, please do not stand on your own :) '** '***********************************************************************************************************************************************************************************************************************************************************************, ************************ Option explicit 'Response.flush DIM Begintime, Endtime Begintime = Timer Dim Conn, SQLSTR, RS, DEFRECORDNUM, Cursorbegin, Cursorend, Curpagenum, HAV, HAV Defrecordnum = 20 '-------------- Get relevant parameters ----------------------------------------------------- If Request ("Cursorbegin") = "THEN CURSORBEGIN = 0 Else Cursorbegin = Request (" Cursorbegin ")) If Request ("CURSOREND") = "The Cursorend = 0 ELSE CURSOREND = Request (" CURSOREND ") If Request ("Curpagenum") <> "THEN Curpagenum = ClNG (Request ("Curpagenum") Ifurpagenum <= 0 then capagenum = 1 Else Curpagenum = 1 End if HAV = Request ("HAV") If hav = "" then hav = "next" '------------------------------------------------------------------------------------------------------------------------------------ '------------显示翻页内容函数-------- Function TurnPageFS (DispRecordnum) Dim n While Not (RS.EOF) and n <dispRecordnum n = n 1 Response.write "<ter>" & _ "<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 the cursorbegin = RS (0) If n = Defrecordnum or RS.EOF TheN CURSOREND = RS (0) Rs.movenext Wend End function '------------------------------------------------------------------------- Set conn = server.createObject ("Adodb.connection") 'SqlStr = "Provider = microsoft.jet.oledb.4.0; data source =" & server.mappath ("mloData.mdb")) Sqlstr = "driver = {sql server}; server = Arbiter; uid = Arbiter; pwd = 123456; database = mldata" "" " conn.open sqlstr '--------- Statistics Total Records/Total Pages ------------------------------- '-PS: Recommended COUNT (ID), ID is automatic number and index, otherwise the speed may be greatly discounted '-PS: This statistics is part of the most consumed resources in this program. If this program is canceled, the speed will be about 10 times faster DIM TOTALRCORDS, TotalPages Sqlstr = "select count (ID) as recornSum from ABC" Set rs = const.execute (SQLSTR, 0,1) TOTALRECORDS = RS ("Recordsum") TotalPages = ABS (int (Totalrecords/DEFRECORDNUM*(-1))) RS.Close Set rs = Nothing '-------- select the corresponding SQL strings based on HAV ------ Select Case (HAV) Case "back" Cursorend = Cursorbegin SqlStr = "select top" & defalecordnum & "_ ID, title, filename, k, imgsize, nameson _ From ABC WHERE ID <"& Cursorbegin & _ "And ID in (Select Top" & DEFRECORDNUM_ & "ID from abc where ID <" & cursorbegin_ & "Order by ID DESC) Order by ID" Case "next" Sqlstr = "select top" & defrecordnum_ & "ID, title, Filename, K, Imgsize, nameson from abc where id>" & cursorend & _ "Order by ID" End select Set rs = const.execute (SQLSTR, 0,1) %>
|