*/ ------------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------
*/From: Jianzheng State Http://www.jzxue.com
*/ Author: Tianya Listen to Rain E-mail: [email protected]: 809252803
*/ Time: 2007-10-6 Programming Forum first launch
*/ Statement: Respect the author's labor, please keep the text in this paragraph
*/ ------------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------
<%
'Name: Million Data Practice
'Author: Tianya Listen to Rain
'Time: October 6, 2007
'Platform: Win2000+IIS5.0+SQL2000
'Affiller: Use it as simple as the first time. Don't scold you ...
'---------------------------------------------------------------------------------------- --------- Connect the database
Response.buffer = true
DIM SQLLOCALNAME, SQLUSERNAME, SQLPASSWORD, SQLDATABAS
Dim connstr, conn
'''' '' '' '' '' '' '' '' '' '' '' '' '' ''
SqllocalName = (local) 'connecting IP [Local (local) ip ip ip]
SQLUSERNAME = SA 'database user name
Sqlpassword = xxxxxx 'user password
Sqldatabasename = news2008 'database name
Connstr = provider = sqloledb; user ID = & sqlusername &; password = & sqlpassword &; initial catalog = & sqldatabasename &; LocalName &;
'''' '' '' '' '' ' '''' '' '' '' '' ' '
On error resume next
Set conn = server.createObject (adodb.connection)
Conn.open connstr
If err then
err.clear
Set conn = nothing
Response.write <div style = 'font-size: 14px; color =#ff0000' align = 'center'> Database connection error, please check the database connection string </div>
Response.end
End if
'---------------------------------------------------------------------------------------- --------- Connect the database to complete
'Define variables
'TBLNAME-Table name; FLDNAME-arrange field name; Fieldname- The field name that needs to be read; pagesizex-paging size; PageCountX-Total pages; Pageno-current page; Ordertype-sorting method; Strwhere-conditional statement statement
'Strsql-Total Execution Statement; FieldCount
Dim Tblname, FLDNAME, Fieldname, PageSizex, PageCountX, Pageno, OrdRETYPE, Strwhere
DIM Strsql, FieldCount, StrTMP, StRORORDER, TOPFIELD
'
Pageno = trim (request.querystring (pageno))
if isnumeric (pageno) or pageno = then 'If there is no Page value, the initialization value
Pageno = ABS (Pageno)
If Pageno = 0 THEN PAGENO = 1
else
Pageno = 1
end if
Tblname = tablenews
FLDNAME = id 'shows that the sorting field value cannot be repeated in the database: It is recommended that the primary key
Fieldname = ID, Title, Addtime
Pagesizex = 30
Ordertype = 1 '0-is the order 1-liter
Strwhere = (code = '0101') and (HITS> 100) 'Note: If a condition is used () double parentheses
Topfield = (Pageno-1)*PageSizex'TOP
if orderype = 0 then
Strtmp = <(Select min
Stroreder = Order by [& FLDNAME &] DESC
else
Strtmp => (Select Max
Stroreder = Order by [& FLDNAME &] ASC
end if
'Define SQL statements
Strsql = Select Top & ClNG (PAGESIZEX) & Fieldname & From & TBLNAME &
if Pageno = 1 Then 'If it is the first page, execute the following code to check the library fast
if Strwhere <> then
Strsql = Strsql & Where & Strwhere & StroRder &
else
Strsql = strsql & strorder
end if
else
if Strwhere <> then
Strsql = Strsql & WHERE & FLDNAME & Strtmp & (& FLDNAME &) From (Select Top & Clng (TopField) & FLDNAME & FRM & TBLName & Strwhere & Str. Order &) as TBLTMP) and & Strwhere & Stroreder &
else
Strsql = Strsql & WHERE & FLDNAME & Strtmp & (& FLDNAME &) From (Select Top & Clng (TopField) & FLDNAME & TBLName & STRRENER & AS TBLTMP) & Stronger &
end if
end if
Set rs = const.execute (strsql) 'execute query
if rs.bof and rs.eof then
Conn.close: set conn = Nothing
response.write <script language = 'javascript'> Alert ('At present, no records are found, please return to re-operation! "); History.go (-1); </script>
response.end
end if
if Strwhere <> THEN 'Seeking Total Records
FieldCount = Conn.execute (Select Count (& FLDNAME &) From & Tblname & Strwhere &) (0) (0)
else
FieldCount = Conn.execute (Select Count (& FLDNAME &) From & TBLNAME &) (0)
end if
if (FieldCount Mod NPAGESIZE)> 0 THEN 'Find the total page number PageCountX
PagecountX = (FieldCount- (FieldCount Mod Mod PageSizex))/ PAGESIZEX +1
else
PagecountX = (FieldCount / PageSizex)
end if
'Display data
do while not rs.eof
Response.Write & RS (Title) && nbsp; & nbsp; & nbsp; Add time: & rs (addtime) & <br/>
rs.movenext
loop
'Turn off and release related resources
RS.Close
Conn.close: set conn = Nothing
'Display paging
if Pageno <= 1 then
Response.write <font color = '#ff0000'> [Homepage] [Previous] </font>
else
Response.write [<a href = '? Pageno = 1' target = '_ seld' title = 'Home'> <font color = '#ff0000'> Home </font> </a>]
Response.write [<a href = '? Pageno = & (pageno-1) &' target = '_ seld' title = 'Previous page'> <font color = '#ff0000'> Previous </font> < /a>]
end if
if Pageno> = PageCountX Then
Response.write <font color = '#ff0000'> [Next page] [Tail Page] </font>
else
Response.write [<a href = '? Pageno = & (pageno+1) &' target = '_ seld' title = 'Next page'> <font color = '#ff0000'> </font> < /a>]
Response.write [<a href = '? Pageno = & PageCountX &' Target = '_ Self' Title = 'Test Page'> <font color = '#ff0000'> Tail Page </font> </a>]
end if
Response.write [page order <font color = red> & pageno & </font> page/common <font color = red> & pageCountX & </font> page]
Response.write [Total <font color = red> & fieldcount & </font> entry <font color = red> & pageSizex & </font> strip/page]
Response.write to: <select name = 'page' size = '1' Onchange = javascript : window.location = '? Pageno ='+this.Options [this.selectEdindex] .value;>
for i = 1 to payCountX
Response.write <option value = & i &
if pageno = I then response.write selectd
Response.write (> No.- & i &-page </option>)
next
Response.write </selectd>
%>