• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP coding help needed: paging results of query

Winchester

Diamond Member
Im building a asp page to display 10 records per page and then be able to sort them by last name and be able to click next and go to the next 10.


If I put the code exactly as below it works fine, except it just shows the first 10 records even when clicking next. It always shows the first 10 records (url right below)

odbcgallery.asp?offset=10



When I click on my respective letter (T or D) for example, it does show only the records starting with those letters. It goes to the 3rd page of records exactly like the above URL. When going to the following link on my site, it should bring up just the records with the last name starting with T (url right below)

odbcgallery.asp?Start=0&Offset=10&LastName=T


-----

 
Make the next button a link with the count you are on. Page 1 would have a next button with StartShowingCount=11. So, if you check the Request("StartShowingCount") and it's greater than 0, you simply "do while i < StartShowingCount; i=i+1; rs.MoveNext; loop" to get to the records you are to display.

If you need a previous button, just make StartShowingCount = (StartShowingCount - RecordsShownPerPage)

Another solution is do it in ASP.NET, select a datagrid, and enable paging.
 
Thanks for the info. Im not up to date on .NET and I havent found many tutorials on connecting to an Access database in ASP.NET etc.
 
Originally posted by: KB
A few comments in your code marked by *******


***Why are you executing this here? You then execute it again later***
Set RS = conn.Execute(SQL_query)



I only find it once
 
Ugh.

You don't need most of the code you have written.

If you use the right type of cursor, you can check the recordcount by doing RS.RecordCount. Also, to do paging you can just move directly to the record number. So if they click next on the first page, you can do RS.Move PageSize * PageNumber. Of course, you need a bit of logic to make sure that's not beyond the last record.
 
There are half a dozen ways to do this. The two most common (depending on amount of data) are:

1] Use Getrows and cycle through an array.

2] Use the Cachesize & Pagesize property of the recordSet object. here
 
I can get both to work individually, but not together

I know how to do paging, it is already working, how can I do a query, then page these results.
 
Back
Top