asp读取数据库中数据到数组的类
时间:2007-09-16 18:19:00
一个asp读取数据库中数据到数组的类,仅供参考!
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
标签:数据,类
0
投稿
猜你喜欢
对YOLOv3模型调用时候的python接口详解
2023-05-31 00:58:57
matplotlib设置legend图例代码示例
2023-04-18 13:20:12
python3下载抖音视频的完整代码
2023-12-24 01:10:42
python清除字符串里非字母字符的方法
2022-08-27 16:04:02
用VBS语言实现的网页计算器源代码
2007-12-26 17:09:00
python 使用百度AI接口进行人脸对比的步骤
2021-07-06 02:20:06
mysql 控制台程序的提示符 prompt 字符串设置
2024-01-26 01:42:11
使用Pytorch+PyG实现MLP的详细过程
2023-05-03 17:48:14
Python常问的100个面试问题汇总(上篇)
2023-12-02 18:56:28
python实现对变位词的判断方法
2022-01-29 04:36:10
Mysql数据库 ALTER 操作详解
2024-01-18 11:03:28
distinct 多列问题结合group by的解决方法
2024-01-21 11:18:23
关于vue中根据用户权限动态添加路由的问题
2024-05-05 09:25:11
MySQL插入中文不乱码的5种方法
2024-01-17 10:47:21
python实现对excel中需要的数据的单元格填充颜色
2023-03-04 13:02:39
python笔记之mean()函数实现求取均值的功能代码
2022-01-12 07:06:47
numpy中轴处理的实现
2021-08-14 12:06:16
利用PyQt5生成过年春联
2023-05-23 21:14:22
PHP面向对象程序设计高级特性详解(接口,继承,抽象类,析构,克隆等)
2023-11-23 11:35:00
oracle 常用的几个SQL
2009-12-01 12:36:00