首 页站长学院免费论文实用文书客户留言繁體中文
设为首页
加入收藏
联系我们
您当前的位置:爱上范文网 -> 站长学院 -> 网站编程 -> ASP教程 -> 文章内容 退出登录 用户管理
栏目导航
· ASP教程 · PHP教程
· JSP教程 · NET教程
· XML教程 · CGI教程
热门文章
· [组图] 2006:浏览器进入多元...
· 个人SMTP服务器的配...
· 不可忽视的BIOS参数...
· 趣话电脑病毒19年发...
· 什么是FTP及什么是F...
· [组图] Frontpage2000实务高...
· [图文] 网络协议X档案全集(...
· 局域网优化的六大秘...
· [组图] 新建Photoshop图像
· [组图] 用FrontPage 2000下...
相关文章
· 使用递归从数据库读...
读取数据库中数据到数组的类
作者:无从考证  来源:转载  发布时间:2005-9-12 9:27:38  发布人:admin

减小字体 增大字体

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

[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登录
Copyright © 2002-2005 23fw.com. All Rights Reserved .