欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

asp access 大数据量的分页的方法

程序员文章站 2024-02-17 08:13:58
...

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












'十万条以上数据的分页的方法
'作者: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
%>


ID 标题 时间

'分页开始
'计算总页数
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
next

if page response.write "..."
end if
if page=CInt(page_count) then
response.write "下一页 最后一页"
else
response.write "下一页 最后一页"
end if

%>