Quote:
Originally posted by shane
An interesting method Matt. The only method of doing paging in SP's that I'd seen used a temp table, which I didn't like, and couldn't think of any other way myself.
My method basically says "If you are on page one, simply grab the first X rows ORDER BY something". "If not, find the ID value of the first record that should be displayed by counting up to number of pages * perpage. Then grab the first X rows where the ID value is greater than or equal to the id value of the first one to show". It is kind of hard to work around the logic but it works well and is fairly efficient. It breaks down if you do not have a primary key or other method to determine 'what number is next' sort of thing.
Quote:
Originally posted by shane
There's still one downside of using SP's to get your RS and that's that you can't use a variable in the ORDER BY clause. As I often use clickable data table headings, to re-sort the data, I often just use SP's to retrieve the RS and then apply the ADO RS's sort property and then page the RS. Any ideas on a better approach?
Well, I know with Sybase if you use Dynamic SQL you can have ORDER BY @var. Otherwise I do something like this: