外包网www.waibao.com.cn
欢迎 游客 , 注册 | 登录 | 会员 | 界面 | 简洁版本 | 在线 | 帮助
外包网论坛(威客,威客网,悬赏任务)

如何成为一名群主?   

发表新主题 回复该主题
本主题被查看41次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第   上一主题   下一主题
标题: ASP读取数据库中数据到数组的类
版主
UID: 16051
来自:
精华: 0
积分: 6673
帖子: 6669
注册: 2008-6-10 11:56:00
状态: 离线
包子皮: 4.00
包子馅: 1670.50 元
只看楼主 2008-11-21 17:43
ASP读取数据库中数据到数组的类
我的身份:公司
认证信息:  未实名认证
基本诚信:0
项目诚信:0
经验积分:26
我的服务范围:
尚未填写
    
以下为引用的内容:
  DbPath = "test.mdb"’数据库位置
  C & 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

                    
#1  
发表新主题 回复该主题
本主题被查看41次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第







现在的时间是 2009-01-09 14:41:53

版权所有 外包网  
         Powered by Discuz!NT 1.0.2656    Copyright © 2001-2009 Comsenz Inc.
Processed in 0.192 seconds