in

ASP.NET Weblogs

uber1024's WebLog

It's not hot wings and beer, but it's still okay

Quick and Dirty paging with SQL Server

I stumbled across this overload for the Fill method of the SqlDataAdapter:

public int Fill(
   DataSet dataSet,
   int startRecord,
   int maxRecords,
   string srcTable
);

So you could do something like:

objDA.Fill(objDS, (intPageSize * (intPageNumber-1)), intPageSize, “TableName”);

I believe that the method will actually return all of the records from your query, but only add the ones you specify to the DataSet.  If that's the case, then I wouldn't recommend using this in a highly performance sensitive application, but if you just need to get something out the door this might be a quick and dirty way to do it.  Much easier than what I did in my last post

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add