Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 19th, 2008, 09:32 PM
Authorized User
Join Date: Feb 2008
Location: london, , United Kingdom.
Posts: 17
Thanks: 3
Thanked 0 Times in 0 Posts
Default asp/Access recordset navigation query

I'm trying to set up a way to navigate through recordsets at 4-6 records per page. I want to simply present url links on the page after the 4-6 records have been shown, so that the next iteration of the loop continues off from where the previous one stopped. at the moment I've just got the data going straight to the page (with some div formatting) and using a rs.movenext within the WHILE NOT rs.EOF ... WEND loop with the result being that ALL the records that match my SQL query will be printed to the page.

Anyone got ideas/suggestions for robust methods?

Thanks in advance,


Reply With Quote
  #2 (permalink)  
Old April 10th, 2008, 01:43 PM
Registered User
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post

There are several ways of doing this. One method is to pass a variable back to the same page that returns your results with the page number such as. .

getresults.asp?pn=2 (where getresults.asp contains the results and pn equals your page number.)
multiply pn by the number of results you want to display.

In your WHILE NOT rs.EOF ... WEND loop count the records returned by adding 1 to the variable after movenext. Add a conditional to check to see if the variable falls on the page. Once all the results of that page have been retrieved Use Exit While to end the loop.

such as:
if PageNumber = 0 then
end if
NoPerPage=4 ' number of record per page
RecordMin=(((PageNumber-1) * NoPerPage)+1) 'starting number of results
if RecordMin < 1 then
end if
RecordMax=PageNumber * NoPerPage 'ending number of results
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & dbPath)
Set objRS = CreateObject("ADODB.Recordset")
objRS.Open sSQL, oConn
do while not objRS.EOF
  if RC >= RecordMin and RC <= RecordMax then
    %><% 'Display your results here
  end if
  if RC > RecordMax then
    exit do
  end if

'put page links here
if PageNumber > 1 then
<a href="results.asp?pn=<%=PageNumber-1%>">&lt;&lt;Prev</a>
End if
if not objRS.EOF
<a href="results.asp?pn=<%=PageNumber+1%>">Next&gt;&gt;</a>
End if
set objRS = nothing
set oConn = nothing

Reply With Quote
The Following User Says Thank You to Frye-Guy For This Useful Post:
murshed (January 16th, 2011)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Access Query from ASP arholly Access ASP 0 January 25th, 2008 03:31 PM
Recordset Pagination (ASP Access) darinsee Classic ASP Databases 9 September 24th, 2004 05:30 PM
MS Access Query using sql/asp redhorse SQL Language 8 March 17th, 2004 05:15 AM
recordset navigation bar... joeore PHP Databases 2 March 4th, 2004 05:49 PM

All times are GMT -4. The time now is 07:24 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.