access| Page | data | Database author: Xiao Moon Scar (Xiaoyuehen)
Address: http://blog.csdn.net/xiaoyuehen/archive/2005/01/17/257202.aspx
Please include the relevant information, thank you.
Main idea: Use a statement statistics (count) out of the record number (but not in the query to get RecordCount property), the slow existence of Cookies, jump without statistics, page jump links also from this, using ADO AbsolutePage properties to set the current page, Returns the Intpagesize record. Write a class for easy invocation, the main place of code has been explained
Hardware environment: AMD Athlon XP 2600+, 256 DDR
Software Environment: MS Windows Advanced Server + IIS 5.0 + Access + IE 6.0
Test results: First run in 250 (first)-400 (last) millisecond, (after the number cached) jumps between pages to stabilize within 47 milliseconds. Page 1th skip to last page no more than 350 milliseconds
Applicable scope: for normal paging. Not applicable to a more complex query: If the condition is "[Title] like '% favorite% '", the query time greatly increased, even if the Title field indexed also useless. :(
<% @LANGUAGE = "VBScript" codepage= "936"%>
<%option explicit%>
<%
Dim Intdatestart
Intdatestart = Timer ()
REM # Open Database connection
Rem #################################################################
function F__openconn ()
Dim Strdbpath
Dim ConnStr
Strdbpath = ".. /db/test.mdb "
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source="
ConnStr = connstr & Server.MapPath (Strdbpath)
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open ConnStr
End Function
Rem #################################################################
REM # Close Database connection
Rem #################################################################
function F__closeconn ()
If IsObject (conn) Then
Conn.close
End If
Set conn = Nothing
End Function
Rem #################################################################
Rem Get Execution time
Rem #################################################################
function Gettimeover (Iflag)
Dim Ttimeover
If Iflag = 1 Then
Ttimeover = FormatNumber (Timer ()-Intdatestart, 6, true)
Gettimeover = "Execution time:" & Ttimeover & "SEC"
Else
Ttimeover = FormatNumber (Timer ()-Intdatestart) * 1000, 3, True)
Gettimeover = "Execution time:" & Ttimeover & "milliseconds"
End If
End Function
Rem #################################################################
Class Cls_pageview
Private sbooinitstate
Private Sstrcookiesname
Private Sstrpageurl
Private Sstrpagevar
Private Sstrtablename
Private sstrfieldslist
Private sstrcondiction
Private sstrorderlist
Private Sstrprimarykey
Private Sintrefresh
Private Sintrecordcount
Private sintpagesize
Private Sintpagenow
Private Sintpagemax
Private Sobjconn
Private Sstrpageinfo
Private Sub Class_Initialize
Call Clearvars ()
End Sub
Private Sub Class_Terminate ()
Set Sobjconn = Nothing
End Sub
Public Sub Clearvars ()
Sbooinitstate = False
Sstrcookiesname = ""
Sstrpageurl = ""
Sstrpagevar = "Page"
Sstrtablename = ""
Sstrfieldslist = ""
Sstrcondiction = ""
Sstrorderlist = ""
Sstrprimarykey = ""
Sintrefresh = 0
Sintrecordcount = 0
Sintpagesize = 0
Sintpagenow = 0
Sintpagemax = 0
End Sub
Rem # Save the number of Cookies in a record
Public Property Let Strcookiesname (Value)
Sstrcookiesname = Value
End Property
Rem # Turn Address
Public Property Let Strpageurl (Value)
Sstrpageurl = Value
End Property
Rem # Table Name
Public Property Let strTableName (Value)
Sstrtablename = Value
End Property
Rem # Field List
Public Property Let Strfieldslist (Value)
Sstrfieldslist = Value
End Property
Rem # Query conditions
Public Property Let Strcondiction (Value)
If Value <> "" Then
Sstrcondiction = "WHERE" & Value
Else
Sstrcondiction = ""
End If
End Property
Rem # # Sort fields, such as: [ID] ASC, [Createdatetime] DESC
Public Property Let Strorderlist (Value)
If Value <> "" Then
Sstrorderlist = "ORDER By" & Value
Else
Sstrorderlist = ""
End If
End Property
Rem # fields used to count records
Public Property Let Strprimarykey (Value)
Sstrprimarykey = Value
End Property
Rem # Number of record bars displayed per page
Public Prope