怎么做输出分页

amadou 2001-03-12 05:25:00
我写了一个数据库的查询程序但查出来的东西很多,我希望能有分页的功能但我不知道怎么做。
...全文
173 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
loneboy 2001-03-13
  • 打赏
  • 举报
回复
同意老大得看法不过觉得代码好像有点太多了阿
hsboy 2001-03-12
  • 打赏
  • 举报
回复
你去看iis带的文档就enough了
amadou 2001-03-12
  • 打赏
  • 举报
回复
老大,能不能介绍一本关于ASP各种对象详细说明的书呀
amadou 2001-03-12
  • 打赏
  • 举报
回复
谢谢老大,好厉害,小菜鸟谢过了
任叔 2001-03-12
  • 打赏
  • 举报
回复
上边的方法只适用于只有一个字段的记录集
多个字段可以这样写:
PageSize = Request.QueryString("PageSize")
CurrentPage = Request.QueryString("CurrentPage")
strSQL = Request.QueryString("strSQL")

Set rs = Server.CreateObject("ADODB.RecordSet")
Set Comm = Server.CreateObject("ADODB.Command")

'用Command控件的方式打开记录集,
'以支持记录集的AbsolutePage属性
Comm.CommandText = strSQL
Comm.CommandType = 1
Set Comm.Activeconnection = Session("objConn")
rs.CacheSize = 5
rs.Open Comm, ,1 ,3
AllCount = rs.RecordCount

'计算总页数,并判断当前页的合法性
intTotalPage = int(AllCount/PageSize+.999)
if cint(CurrentPage) > cint(intTotalPage) then
CurrentPage = intTotalPage
end if
if cint(CurrentPage) < 1 then
CurrentPage = 1
end if

'跳至当前页
if not rs.EOF then
rs.MoveFirst
rs.PageSize = PageSize
rs.AbsolutePage = cint(CurrentPage)
end if

'获取本页的记录数
ProjNum = 0
Do Until rs.eof
ProjNum = ProjNum + 1
rs.MoveNext
if ProjNum = rs.PageSize then
Exit Do
end if
Loop
ProjCount = ProjNum
if ProjCount > 0 then rs.AbsolutePage = CurrentPage
任叔 2001-03-12
  • 打赏
  • 举报
回复
比如:
CurrentPage = 2 '显示第二页
PageSize = 20 '每页显示20个
for i=(CurrentPage-1)*PageSize+1 to CurrentPage*PageSize
response.write rs(i)
next
任叔 2001-03-12
  • 打赏
  • 举报
回复
比如:
CurrentPage = 2 '显示第二页
PageSize = 20 '每页显示20个
for i=(CurrentPage-1)*PageSize+1 to CurrentPage*PageSize
response.write rs(i)
next
任叔 2001-03-12
  • 打赏
  • 举报
回复
用记录集(rs)保存所有结果,然后通过循环逐个显示,可以自己控制没页显示数目

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧