• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 讀取數據庫中數據到數組的類

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    DbPath="test.mdb"’ 數據庫 位置 ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="Server.MapPath(DbPath) SetConn=Server.CreateObject("ADODB.Connection") Conn.openConnStr ClassClass_Read PublicArr,Rs,SQL,ArrTR,Arr TD ,Page,TotalRead,Tot
    DbPath = "test.mdb"’數據庫位置
    ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(DbPath)
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.open ConnStr

    Class Class_Read
    Public Arr,Rs,SQL,ArrTR,ArrTD,Page,TotalRead,TotalPage
    Public Function Read(SQL,TD,TR,PG)
    SQL = Replace(SQL,"’","")
    Page= Int(PG)
    Set Rs = Server.CreateObject("ADODB.Recordset") : Rs.open SQL,conn,1,1
    TotalRead= Rs.RecordCount
    If TotalRead>0 Then
    If TR>0 Then : Rs.PageSize = TR : Else : TR=TotalRead
    If TD>Rs.Fields.Count or TD<1 Then TD = Rs.Fields.Count
    If TotalRead Mod TR <>0 Then TotalPage = 1 : End If : TotalPage = TotalPage + Int(TotalRead/TR)
    If Page>=TotalPage Then Page=TotalPage : TR = TotalRead-TR*(TotalPage-1)
    If Page>1 Then Rs.absolutePage=Page Else Page=1
    End If
    reDim Arr(TD-1,TR)
    For ArrTR = 0 to TR-1 : If Rs.Eof Then Exit For
    For ArrTD = 0 to TD-1 : Arr(ArrTD,ArrTR) = Rs(ArrTD) : Next : Rs.MoveNext
    Next
    ArrTR = ArrTR-1
    Rs.Close
    Set Rs=Nothing
    End Function
    End Class
    ’使用方法
    Dim C:Set C = New Class_Read
    C.Read ("SQL語句","讀取列數","讀取行數[既每頁顯示條數]","當前頁數")
    Dim i
    For i=0 To C.ArrTR
    Response.Write "<br>內容:"&C.Arr(0,i)
    Next
    Response.Write "<br>總記錄條數:"&C.TotalRead
    Response.Write "<br>總頁數 :"&C.TotalPage
    Response.Write "<br>當前頁 :"&C.Page
    Response.Write "<br>當前記錄數:"&C.ArrTR+1

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>