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
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器