asp教程 access 大 数据 量的分页的 方法 '本款分页效果支持'分页,分页效果:首页 上一页 ... 2 3 4 5 6 7 ... 下一页 最后一页这种分页模式,有论坛风格 'idtitlecontentstatusupdatetime '1t1c112010-5-26 21:16:06 '2t2c212010-5-26 21:16:09 '3t3c312010
asp教程 access 大数据量的分页的方法
'本款分页效果支持'分页,分页效果:首页 上一页 ... 2 3 4 5 6 7 ... 下一页 最后一页这种分页模式,有论坛风格
'id title content status updatetime
'1 t1 c1 1 2010-5-26 21:16:06
'2 t2 c2 1 2010-5-26 21:16:09
'3 t3 c3 1 2010-5-26 21:16:12
'4 t4 c4 1 2010-5-26 21:16:15
'5 t5 c5 1 2010-5-26 21:16:23
db=database/db1.mdb
path=server.mappath(db)
set conn=server.createobject(adodb.connection)
connstr=provider=microsoft.jet.oledb.4.0;data source=&path
conn.open connstr
set rs=server.createobject(adodb.recordset)
%>
new document
id
标题
时间
'十万条以上数据的分页的方法
'作者:wangsdong
'来源:111cn.net
'原创文件,转载请保留此信息,谢谢
keyword=request(keyword)
page=request(page)
if page= or not isnumeric(page) then page=1 else page=cint(page)
page_size=2
q1= and status>0
if keyword请输入关键词 and keyword then
q1=q1& and title like '%&keyword&%'
end if
if page>1 then
sql=select top &page_size& id,title,content,updatetime from news where 1=1 and id0&q1& order by id desc) as c1)
else
sql=select top &page_size& id,title,content,updatetime from news where 1=1
end if
sql=sql&q1& order by id desc
set rs=server.createobject(adodb.recordset)
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
id=rs(id)
title=rs(title)
content=rs(content)
updatetime=rs(updatetime)
'*************循环的内容开始************************
%>
'*************循环的内容结束************************
rs.movenext
loop
end if
rs.close
%>
'分页开始
'计算总页数
page_count=1
sql=select count(*) as t from news where 1=1&q1
rs.open sql,conn,1,1
if rs.eof then
else
recordset_count=rs(t)
if recordset_count mod page_size=0 then
page_count=recordset_countpage_size
else
page_count=recordset_countpage_size+1
end if
end if
rs.close
'分页,分页效果:首页 上一页 ... 2 3 4 5 6 7 ... 下一页 最后一页
if page=1 then
response.write 首页 上一页
else
response.write 首页 上一页
end if
if page>4 then
s=page-3
response.write ...
else
s=1
end if
if page e=page+3
else
e=page_count
end if
for i=s to e
if i=page then
response.write &i&
else
response.write &i&
end if
nextif page response.write ...
end if
if page=cint(page_count) then
response.write 下一页 最后一页
else
response.write 下一页 最后一页
end if
%>