Paging through a recordset
by Daniel Adrian
Skill level: Beginner
First posted: Monday, October 09, 2000
Paging through a recordset
When I want to develop an application with a lot of records to show, I make pages so I can easily navigate
through the database and make the page look good and load quickly.
This can be done very easily. Shall we start?
Take a look at these next lines of code:
If Request.QueryString("Page") = "" Then
Page = 1
Else
Page = Request.QueryString("Page")
End If
recordsToShow = 20
n = 0
These lines of code are saying if the value of Request.QueryString("Page") is without any value then page
=1 else page gets the page the user requested. Recordstoshow is the number of lines in each page.
N is number of records printed.
Now lets put it into action:
objrs.PageSize = recordsToShow
(objrs is ADODB.Recordset Object)
In pagesize we are telling the record set that every page will have 20 records because recordstoshow is 20.
Now let’s pull out some records:
Do until objrs.EOF
if n = recordsToShow then
exit do
end if
write what that you want here
n=n+1
loop
Now we are writing date for the database and every time that we are repeating the loop we check if we done
it 20 times some when it’s 20 we will stop the loop.
Now let’s write the navigation:
if Page <> 1 then
Response.Write ""
end if
Response.Write "<< Back "
if Page <> 1 then
Response.Write ""
end if
'-------------------------
For intCount = 1 to objRs.PageCount
If intCount = 1 then
Response.Write " | "
End If
If cint(intCount) = cint(Page) then
Response.Write "" & intCount & "| "
Else
Response.Write "" & intCount & " | "
End If
Next
'-------------------------
if cint(page) = cint(objRs.PageCount) then
Response.Write ""
end if
Response.Write " Next >> "
if cint(Page) = cint(objRs.PageCount) then
Response.Write ""
end if
First we are checking if the current page is not 1 so it’s more then one so we can go back.
After this we need to write all of the pages in the record set.
Now we need to check if we can do next.
That is all! Yes it’s that easy!
相关视频
相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
热门文章 没有查询到任何记录。
最新文章
VB.NET 2005编写定时关
Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速
人气排行 轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案
查看所有0条评论>>