SQL Query for Datagrid Paging

  • Thread starter Thread starter IntraRELY
  • Start date Start date
I

IntraRELY

I under stand how to pull the results for all but the first page in the grid
using one query or stored proc. If I could specify TOP 0 in the sub query,
you would think that would work. Do I need to create another stored proc to
pull the results for the first page of the datagrid?

SELECT TOP 3 id, name
FROM mytable
WHERE id NOT IN
(SELECT TOP 0 id FROM myTable ORDER BY name)
ORDER BY name

TIA,

Steve
 
I personally have never tried using Top in a subquery but I assume it would work.... You have the Query what happens if you run it in SQL Query Analyzer?

As far as DataGrid paging, here are a couple of KB Articles that show some techniques for doing this. Since you didn't specify whether this was Windowsform or Webforms I
include links to both...

Windowsforms datagrid:
305271 HOW TO: Perform Paging with the DataGrid Windows Control by Using Visual
http://support.microsoft.com/?id=305271

Web forms DataGrid:
318131 HOW TO: Page Through a Query Result for Better Performance
http://support.microsoft.com/?id=318131



Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.




--------------------
 
Back
Top