ASP读取数据库中数据到数组的类
2009-06-10 12:31
323 查看
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
相关文章推荐
- 关于“Asp.net 中后台CS读取数据库数据生成数组传递给前台页面JS使用”
- php实现通用的从数据库表读取数据到数组的函数实例
- ASP.NET数据库使用精典-----读取数据库中数据
- asp.net中从数据库中读取数据,有对应的吧checkbox选中
- [ASP.net]从数据库中读取数据自动生成XML
- Javascript+XMLHttpRequest+asp.net无刷新读取数据库数据
- ASP.NET数据库使用精典-----读取数据库中数据
- asp怎么在类里写函数调用数据库读取数据
- asp.net 读取Excel数据并将数据插入到数据库中
- asp.net中读取数据库数据的方法
- (转)ASP.NET 2.0 从数据库中读取数据生成分层的结构化TreeView
- Javascript+XMLHttpRequest+asp.net无刷新读取数据库数据
- asp.net开发中使用EF无法及时读取数据库数据
- ASP.NET数据库使用精典-----读取数据库中数据
- Javascript+XMLHttpRequest+asp.net无刷新读取数据库数据
- asp.net 从数据库中读取而二进制数据图片,展示在Image中
- asp.net中读取数据库数据代码
- asp.net连接数据库读取数据示例分享
- asp.net ajaxtoolkit CascadingDropDown从数据库中读取数据绑定到DropDownList控件上
- asp下拉列表框 怎么读取数据库中的数据