当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP读取数据库中数据到数组的类

ASP
在线实时开通FTP&WEB
对文件的操作--建立移动删除文件夹
利用FSO取得BMP,JPG,PNG,GIF文件信息
三种禁用FileSystemObject组件的方法
在线修改Serv-U 4.2用户密码
asp 中常用的文件处理函数
FSO+递归生成文件列表(xml)
文件遍历排序函数
清空iis log 中自己登录ip的vbs
NAV导致IIS调用FSO失败的解决方法
构建免受 FSO 威胁虚拟主机(三)
构建免受 FSO 威胁虚拟主机(二)
构建免受 FSO 威胁虚拟主机(一)
类似于iis浏览的功能
巧用FileSystem组件实现WEB应用中的本地特定打印
ASP中FSO对象对IIS WEB服务器数据安全的威胁及对策
文件的读出 编辑 管理
怎样判断一个盘上是否有文件
用ASP实现对MP3曲目信息的操作
关于用ADO STREAM做的无组件上传程序简单介绍

ASP读取数据库中数据到数组的类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 131 ::
收藏到网摘: n/a

以下为引用的内容:
  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