How to ''page'' through records?

  • I have a search utility in a program that lets users create an ad hoc query like (SELECT PartNumber, PartDescription FROM PartMaster WHERE PartDescription LIKE '%elbow%'), or something like that.

    I have the row limit set to 100.  If there are more than 100 records that satisfy the query, I would like to be able to 'page' through the records 100 at a time using a Next button.

    How do you do this?

    Using VB6/ADO/SQL 2000

    Thanks,

    Jim Shipley

  • depends on the table structure

    but normally for the 1st 100

    select top 100 * from mytable order by dateadded

    then for the second 100

    select top 100 * from mytable where id not in( select top 100 id from mytable order by dateadded) order by dateadded

    etc etc etc

    MVDBA

  • what is the 'dateadded' field?

    Thanks

  • just one i made up to demo the principal

    you need to order the results in some sort of order to be able to effectively say this is the 101st record in the recordset if it's order by "mydate" or whatever

    MVDBA

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply