<% @LANGUAGE = "VBScript" codepage= "936"%>
<%option explicit%>
<!--#include file= "cls_pageview.asp"-->
Class Cls_pageview
Private sbooinitstate
Private Sstrpageurl
Private Sstrpagevar
Private Sstrsql
Private Sstrsqlcount
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
Sstrpageurl = ""
Sstrpagevar = "Page"
Sintrecordcount = 0
Sintpagesize = 20
Sintpagenow = 0
Sintpagemax = 0
End Sub
Private Sub Clearmainvars ()
Sstrsql = ""
End Sub
REM # SQL statements
Public Property Let strSQL (Value)
Sstrsql = Value
End Property
REM # SQL statements
Public Property Let Strsqlcount (Value)
Sstrsqlcount = Value
End Property
Rem # Turn Address
Public Property Let Strpageurl (Value)
Sstrpageurl = Value
End Property
Rem # Number of record bars displayed per page
Public Property Let Intpagesize (Value)
Sintpagesize = Tonum (Value, 20)
End Property
REM # Database Connection objects
Public Property Let objconn (Value)
Set Sobjconn = Value
End Property
Rem # Current Page
Public Property Let Intpagenow (Value)
Sintpagenow = Tonum (Value, 1)
End Property
Rem # Set Total records
Public Property Let Intrecordcount (Value)
Sintrecordcount = Tonum (Value,-1)
If Sintrecordcount < 0 Then Sintrecordcount =-1
End Property
Rem # page Parameters
Public Property Let Strpagevar (Value)
Sstrpagevar = Value
End Property
Rem # Get Current page
Public Property Get Intpagenow ()
Intpagenow = Singpagenow
End Property
REM # page Paging information
Public Property Get strPageInfo ()
strPageInfo = Sstrpageinfo
End Property
Rem # Gets a recordset, two-dimensional array, or string that must be judged using IsArray () in the cycle output.
Public Property Get Arrrecordinfo ()
Call Initclass ()
If not sbooinitstate Then
Response.Write ("Page class initialization failed, please check each parameter condition")
Exit Property
End If
Dim RS, SQL
sql = Sstrsql
Set rs = Server.CreateObject ("Adodb.recordset")
Rem if the record Count statement is not empty, take the first field value as the number of records after the statement is executed
If sstrsqlcount <> "" Then
Rs. Open Sstrsqlcount, Sobjconn, 1, 1
If not (rs.eof or RS.BOF) Then
Sintrecordcount = RS (0)
Else
Sintrecordcount = 0
End If
Rs. Close
End If
Rs.Open sql, Sobjconn, 1, 1
Rem If there is no record statistic statement and the total number of records is not set, then the Recordset RecordCount property is derived.
If Sintrecordcount < 0 Then
Sintrecordcount = Rs. RecordCount
End If
If Sintrecordcount < 0 Then Sintrecordcount = 0
' Raw ingredient page information
Call Initpageinfo ()
If not (rs.eof or RS.BOF) Then
Rs. PageSize = Sintpagesize
Rs. AbsolutePage = Sintpagenow
If not (rs.eof or RS.BOF) Then
Arrrecordinfo = Rs.getrows (sintpagesize)
Else
Arrrecordinfo = ""
End If
Else
Arrrecordinfo = ""
End If
Rs.close
Set rs = Nothing
Call Clearmainvars ()
End Property
Rem # Initialize Paging information
Private Sub Initpageinfo ()
Sstrpageinfo = ""
Dim sURL
sURL = Sstrpageurl
If Instr (1, sURL, "?", 1) > 0 Then
sURL = sURL & "&" & Sstrpagevar & "="
Else
sURL = sURL & "?" & sstrpagevar & "="
End If
If sintpagenow <= 0 Then sintpagenow = 1
If sintrecordcount MoD sintpagesize = 0 Then
Sintpagemax = Sintrecordcount sintpagesize
Else
Sintpagemax = Sintrecordcount Sintpagesize + 1
End If
If sintpagenow > Sintpagemax Then sintpagenow = Sintpagemax
If Sintpagenow <= 1 Then
Sstrpageinfo = "First Prev"
Else
Sstrpageinfo = sstrpageinfo & "<a href=" "& sURL &" 1 "" > Home </a> "
Sstrpageinfo = sstrpageinfo & "<a href=" "& sURL & (sintPageNow-1) &" "> Previous page </a>"
End If
If Sintpagemax-sintpagenow < 1 Then
Sstrpageinfo = Sstrpageinfo & "Next last Page"
Else
Sstrpageinfo = sstrpageinfo & "<a href=" "& sURL & (Sintpagenow + 1) &" "> Next page </a>
Sstrpageinfo = sstrpageinfo & "<a href=" "& sURL & Sintpagemax &" "> Last </a>"
End If
Sstrpageinfo = sstrpageinfo & "page: <strong><font color=" "#990000" ">" & Sintpagenow & "</font& Gt /"& Sintpagemax &" </strong> "
Sstrpageinfo = sstrpageinfo & "Total <strong>" & Sintrecordcount & "</strong> record <strong>" &am P Sintpagesize & "</strong> bar/page"
End Sub
Rem # Long Integer Conversion
Private function Tonum (S, Default)
s = S & ""
If s <> "" and IsNumeric (s) Then
Tonum = CLng (s)
Else
Tonum = Default
End If
End Function
REM # class Initialization
Public Sub Initclass ()
Sbooinitstate = True
If Not (IsObject (sobjconn)) Then
Sbooinitstate = False
Response.Write ("Database connection not specified")
Response. End ()
End If
If Trim (sstrsql) = "" Then
Sbooinitstate = False
Response.Write ("SQL statement unspecified")
Response. End ()
End If
Sintpagesize = Tonum (sintpagesize, 20)
If (Sintpagesize < 1) Or (Sintpagesize >) Then
Sbooinitstate = False
Response.Write ("The number of episodes per page is not set or does not conform to the rule (1-100)")
Response. End ()
End If
Sintpagenow = Tonum (Sintpagenow, 1)
Sintrecordcount =-1
End Sub
End Class
<%
Response. Buffer = True
Dim Intdatestart
Intdatestart = Timer ()
REM # Open Database connection
Rem #################################################################
function F__openconn ()
Dim Strdbpath
Dim ConnStr
Strdbpath = "./db.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 = "Page Execution time:" & Ttimeover & "SEC"
Else
Ttimeover = FormatNumber (Timer ()-Intdatestart) * 1000, 3, True)
gettimeover = "Page Execution time:" & Ttimeover & "milliseconds"
End If
End Function
Rem #################################################################
Dim Strlocalurl
Strlocalurl = Request. ServerVariables ("Script_name")
Dim Intpagenow
Intpagenow = Request. QueryString ("page")
Dim Intpagesize, strPageInfo
Intpagesize = 30
Dim Arrrecordinfo, I
Dim Conn, SQL, SqlCount
sql = "SELECT [ID], [AAAA], [bbbb], [CCCC]" & _
"From [table1]" & _
"Order BY [ID] DESC"
SqlCount = "Select Count ([ID])" & _
"From [table1]"
F__openconn
Dim Clsrecordinfo
Set Clsrecordinfo = New Cls_pageview
Rem Recordset Count priority order: Strsqlcount >> Intrecordcount
Rem is when Strsqlcount has a value, Intrecordcount does not work
Rem therefore, to manually set the total number of records, set Intrecordcount, Strsqlcount leave blank
Rem If none of the above is set, take the strSQL RecordCount property after execution.
Clsrecordinfo.intrecordcount = 2816
Clsrecordinfo.strsqlcount = SqlCount
Rem the total number of records is computed by this statement because the Strsqlcount is set.
Rem set SQL query statement
Clsrecordinfo.strsql = sql
Rem sets the number of display per page
Clsrecordinfo.intpagesize = Intpagesize
Rem Settings Current Display page
Clsrecordinfo.intpagenow = Intpagenow
Rem Settings turn to page
Clsrecordinfo.strpageurl = Strlocalurl
Rem Set Page Steering parameters
Clsrecordinfo.strpagevar = "Page"
Clsrecordinfo.objconn = Conn
Arrrecordinfo = Clsrecordinfo.arrrecordinfo
strPageInfo = Clsrecordinfo.strpageinfo
Set Clsrecordinfo = Nothing
F__closeconn
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Xiao Month Mark General Page class 1.2 test </title>
<link rel= "stylesheet" href= "Page.css" type= "Text/css" >
<body bgcolor= "#FFFFFF" text= "#000000" >
<div class= "PageView" >
<table width= "760" border= "1" cellspacing= "0" cellpadding= "4" align= "center" bordercolordark= "#FFFFFF" bordercolorlight= "#CCCCCC" >
<TR align= "center" >
<TD width= ">ID</td>"
<TD width= > Title </td>
<TD width= "*" > Content (Display first 20 words) </td>
<TD width= > Time </td>
</tr>
<%
Dim bgcolor
If IsArray (arrrecordinfo) Then
For i = 0 to UBound (arrrecordinfo, 2)
Bgcolor= "#FFFFFF"
If I mod 2=0 then bgcolor= "#DFEFFF"
%>
<tr bgcolor= "<%=bgColor%>" >
<TD width= "><%= Arrrecordinfo" (0, I)%></td>
<TD width= "><%=" arrrecordinfo (1, i)%></td>
<TD width= "*" ><%= arrrecordinfo (2, i)%></td>
<TD width= "><%=" Arrrecordinfo (3, i)%></td>
</tr>
<%
Next
End If
%>
</table>
</div>
<table width= "760" border= "0" cellspacing= "0" cellpadding= "4" >
<tr>
<td><%= strpageinfo%></td>
</tr>
<tr>
<TD align= "center" ><%= gettimeover (0)%></td>
</tr>
</table>
</body>