日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

简单的分页类

發布時間:2023/12/20 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 简单的分页类 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.



<%@ Language=VBScript %><% Option Explicit %><SCRIPT LANGUAGE=VBScript RUNAT=SERVER>? '確保引用 ADO Typelib 或使用 ADOVBS.Inc? Dim iPageNum, iRowsPerPage

? Main??? Sub Main()?? Dim rst?? Dim sSQL, sConnString

?? If Request.QueryString("iPageNum") = "" Then???? iPageNum = 1?? Else???? iPageNum = Request.QueryString("iPageNum")???? iPageNum = CInt(iPageNum)?? End If

?? iRowsPerPage = 10

?? sConnString = "Provider=SQLOLEDB.1;password=Xyz123;user id=WebUser;" & _ ???????? "Initial Catalog=NorthWind;Data Source=MySQLServer;" & _ ???????? "network=dbmssocn;"

?? '下列 SQL 從 SQL 視圖中檢索所有列。?? '要優化性能:?? '- 使用存儲過程、視圖或在 SELECT 中指定列?? '- 使用限制返回的記錄的條件(例如,WHERE 子句)?? sSQL = "SELECT CategoryName, ProductName, QuantityPerUnit,"?? sSQL = sSQL & "UnitsInStock, Discontinued"????? sSQL = sSQL & " FROM [Products By Category]"

?? Set rst = GetRecords(sConnString, sSQL)

?? WriteTableHeader rst?? WriteTableBody rst, iRowsPerPage, iPageNum?? ShowNavBar rst

?? 'ShowFastNavBar 方法不使用 RecordCount?? '或 PageCount,所以它重試的記錄數僅等于?? '記錄集的 CacheSize 指定的數量。

?? 'ShowFastNavBar rst

?? CleanUp rst? End Sub

? Function GetRecords(sConnString, sSQL)? Dim cnn? Dim rst

??? set cnn = Server.CreateObject("ADODB.CONNECTION")??? cnn.ConnectionString = sConnString??? nn.Open

??? Set rst = Server.CreateObject("ADODB.RECORDSET")

??? Set rst.ActiveConnection = cnn

???? '當記錄集打開時,adUseClient 的 CursorLocation???? ' 將檢索所有的記錄。???? 'adUseServer 允許沿用 CacheSize???? rst.CursorLocation = adUseServer

???? '在使用服務器端游標時,CacheSize? ???? '限制了取回的行數。我們將只抓取正在顯示的???? '的記錄的數目 - iRowsPerPage???? rst.CacheSize = iRowsPerPage

???? rst.Open sSQL,,adOpenStatic, adLockReadOnly牋????? Set GetRecords = rst??? end Function

??? Sub WriteTableHeader(rst)??? Dim fld

???? Response.Write "<TABLE WIDTH=80% BORDER=1>"???? Response.Write "<TR>"

???? '建立表的列標題????? For Each fld in rst.Fields?????? Response.Write "<TD><B>" & fld.Name & "</B></TD>"??? Next??? Response.Write "</TR>"?? End Sub

?? Sub WriteTableBody(rst, iRowsPerPage, iPageNum)?? Dim iLoop?? Dim fld

?? iLoop = 1

?? rst.PageSize = iRowsPerPage?? rst.AbsolutePage = iPageNum

?? '寫出記錄的當前頁?? Do While (Not rst.EOF) and (iLoop <= iRowsPerPage)???? Response.Write "<TR>"????? For Each fld in rst.Fields?????? Response.Write "<TD>" & fld.value & "</TD>"??????? Next???????? iLoop = iLoop + 1???????? rst.MoveNext???????? Response.Write "</TR>"???? Loop???? Response.Write "</TABLE>"?? End Sub

?? Sub ShowNavBar(rst)?? Dim iPageCount?? Dim iLoop?? Dim sScriptName

??? '本版本提供了更豐富的用戶導航,但是??? '依賴于 RecordCount 和 PageCount,??? '它抵消了為服務器端游標??? '指定 CacheSize 的好處。

??? Response.Write "<BR><BR>"??? sScriptName = Request.ServerVariables("SCRIPT_NAME")

??? If iPageNum > 1 Then????? Response.Write " <a href=" & sScriptName & "?iPageNum="????? Response.Write (iPageNum -1) & "><< Previous</a>"??? End If

??? iPageCount = rst.PageCount??? Do Until iLoop > iPageCount??? f iLoop = iPageNum Then?????? Response.Write " <B>" & CStr(iLoop) & "</B>"????? Else?????? Response.Write " <a href=" & sScriptName & "?iPageNum=" & _?????? Cstr(iLoop) & ">" & iLoop & "</a>"?????? End If?????? iLoop = iLoop + 1??? Loop

??? If Not rst.EOF Then???? Response.Write " <a href=" & sScriptName & "?iPageNum="???? Response.Write (iPageNum +1) & "> Next >></a><BR>"??? Else?????? Response.Write "<BR>"??? End If

??? Response.Write "Page " & iPageNum & " of " & iPageCount & "<BR>"??? Response.Write rst.RecordCount & " Records" 牋??? End Sub

?? Sub ShowFastNavBar(rst)?? Dim iPageCount?? Dim iLoop?? Dim sScriptName

???? '在指定 CacheSize 和使用服務器端游標時,???? '該方法特別有效,因為它不使用 RecordCount ???? '和 PageCount。需要用戶具有經驗。

???? Response.Write "<BR><BR>"???? sScriptName = Request.ServerVariables("SCRIPT_NAME")

???? If iPageNum > 1 Then????? Response.Write " <a href=" & sScriptName & "?iPageNum="????? Response.Write (iPageNum -1) & "><< Previous</a>"??? End If

??? If Not rst.EOF Then????? Response.Write " <a href=" & sScriptName & "?iPageNum="????? Response.Write (iPageNum +1) & "> Next >></a><BR>"??? Else????? Response.Write "<BR>"??? End If

??? Response.Write "Page " & iPageNum

?? End Sub

?? Sub CleanUp(rst)???? If Not rst Is Nothing then?????? If rst.state = adStateOpen then rst.close?????? set rst = nothing???? End If?? End Sub

</SCRIPT>

轉載于:https://www.cnblogs.com/spring4/archive/2005/04/24/2483883.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的简单的分页类的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。