RE: Best way to return a select number of rows?
From: Kevin Yu [MSFT] (v-kevy_at_online.microsoft.com)
Date: 02/13/04
- Next message: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Previous message: Dianne Howard: "Re: Datatables and relations?"
- In reply to: Jeff: "Best way to return a select number of rows?"
- Next in thread: Jeff: "Re: Best way to return a select number of rows?"
- Reply: Jeff: "Re: Best way to return a select number of rows?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 13 Feb 2004 09:22:10 GMT
Hi Jeff,
Thank you for posting in the community!
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get certain number of
records from the server begin with certain index. If there is anything
unclear, please feel free to let me know.
Generally, we can achieve this in two ways.
1. We can do this on the server side. We can modify the stored procedure to
make it return the result set which only contains the specified records.
This is fast, because all the jobs are done on the server side. However, as
you mentioned this is quite complicated and has to make one for each query.
2. There is an overload in SqlDataAdapter.Fill method public int
Fill(DataSet dataSet, int startRecord, int maxRecords, string srcTable);
This overload can fill a certain number of result set into DataSet from a
start index. I think this might match your requirement. However, it might
be a little slower than the first method. Here I write a code snippet for
paging:
private DataSet GetPagedRecords(int page)
{
const int iNum = 9;
int iStart = (page - 1) * iNum;
DataSet ds = new DataSet();
this.sqlDataAdapter1.Fill(ds, iStart, iNum, "Table1");
return ds;
}
Hope this helps. Does this answer your question? If anything is unclear,
please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
- Next message: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Previous message: Dianne Howard: "Re: Datatables and relations?"
- In reply to: Jeff: "Best way to return a select number of rows?"
- Next in thread: Jeff: "Re: Best way to return a select number of rows?"
- Reply: Jeff: "Re: Best way to return a select number of rows?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|