function | data | show <%
REM-----------------------------------
REM Author: Wang Qin army qinjunit@yahoo.com
REm Creation Date: 2004-10-12
REM Modification Date: Monday, January 24, 2005
REM-----------------------------------
' Function practical data paging display function
' parameter: Datasql SQL statement-----------current page data
' Parameters: Countsql-----------The SQL statement that queries the total number of bars
' Parameters: Page-----------which pages
' Parameters: PageSize-----------page times
' Parameters: theadstrings-------Display the header column name definition, separated by "," and corresponds to the column name inside the Datasql.
' Example: =======================================
' <!--#include virtual= ' inc/conn.asp '-->
' <!--#include virtual= ' inc/rw_datapager.asp '-->
' <%
' Dim ipagesize,curpage
' Ipagesize = 18
' Curpage = 1
' If (Request.Form <> "") Then
' If IsEmpty (Request.Form ("P")) then
' Curpage = 1
' ElseIf isnumeric (Request.Form ("P")) then
' Curpage = CLng (Request.Form ("P"))
' End If
' End If
' Showrecords ' exec p_show accounts, "&iPageSize&", "&CurPage&", ' Account_code,account_password, Account_serial,account_type,account_money,stock_time ' "," SELECT count (Account_code) as total from [accounts] ", CLng ( Curpage), ipagesize, "card number, password, serial number, card type, card amount, warehousing time"
' Closedb ()
'% >
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Showrecords (datasql,countsql,page,pagesize,modelstrings,theadstrings)
Dim total,rs,datmessages
Dim Usedatamodel
if (Request.Form ("Pagertotal") <> "") Then
Total = CLng (Request.Form ("Pagertotal"))
Else
Total = Conn.execute (Countsql) (0)
End If
If Len (modelstrings) <8 Then ' stencil length is defined here as 8
Usedatamodel = False
Else
Usedatamodel = True
End If
Datmessages = datmessages & "<table width=" "100%" "border=" "0" "align=" "Center" "cellpadding=" "0" "cellspacing=" "0" "style=" "Border-collapse:collapse;word-break:break-all" ">"
Datmessages = datmessages & "<form name=" "Frmpager" "id=" "Frmpager" "method=" "POST" > "
If CLNG (total) <> 0 Then
' Set rs = Conn.execute (datasql)
REM non-stored procedure paging ====================
Set Rs=server.createobject ("ADODB. RECORDSET ")
Rs. Open datasql,conn,1,1
Rs. Pagesize=pagesize
Rs. Absolutepage=page
REM ==================================
Dim tharray,colcount,k,thstr,i
i = 1 ' initialization register
ColCount = Rs. Fields.Count ' Get total number of columns
If not Usedatamodel then ' do not use stencil operation
If Len (theadstrings) <1 Then
For k = 0 to (Rs. FIELDS.COUNT-1)
Thstr = thstr & Rs. Fields (k) .name& ","
Next
Tharray = Split ((Mid (Thstr,1,len (THSTR)-1)), ","
Else
Tharray = Split (Theadstrings, ",")
End If
Datmessages = datmessages & "<tr bgcolor=" "#BFE8FB" ">"
For K=0 to (COLCOUNT-1)
Datmessages = datmessages & "<th class= ' Hyxxtext ' >" &tharray (k) & "</th>"
Next
Datmessages = datmessages & "</tr>"
Else
Datmessages = datmessages & "<tr><td>"
End If
'---------data cycle begins------------'
while (not rs.eof and i<pagesize)
If not Usedatamodel then
if (I mod 2 =0) Then
Datmessages = datmessages & "<tr bgcolor=" "#E1F4FD" ">"
Else
Datmessages = datmessages & "<tr bgcolor=" "#FFFFFF" ">"
End If
For K=0 to (COLCOUNT-1)
Datmessages = datmessages & "<td>" &rs (k) & "</td>"
Next
Datmessages = datmessages & "</tr>"
Else ' Bulk replace template data
Dim onenotestring
onenotestring = modelstrings
For K=0 to (COLCOUNT-1)
If IsNull (RS (k)) then
onenotestring = Replace (onenotestring, "{$DATA #" & (K+1) & "}", "")
Else
onenotestring = Replace (onenotestring, "{$DATA #" & (K+1) & "}", Htmlstring (RS (k))