Re: Best way to return a select number of rows?
From: Jeff (jrendl_at_spammer.org)
Date: 02/13/04
- Next message: ShijuFrancis: "RE: Binding with a DataRelation"
- Previous message: wjer: "Way to loop code for inserting Checkboxlist values into DB?"
- In reply to: Kevin Yu [MSFT]: "RE: Best way to return a select number of rows?"
- Next in thread: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Reply: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 13 Feb 2004 14:43:04 -0600
Am I missing something here? I figure I must be.
In my example, I only have 1000 records, but I could eventually have 10000
or more. I do NOT want to return that many records under any circumstance.
This makes the .fill method unacceptable. I've also been told that I should
keep application logic in the application and database logic in the
database. Using the Stored Procedure in this manner goes directly against
that and is not a good solution, it just happened to give the desired
results.
With DAO and the previous ADO, I could just do a Move Next, so I could have
a loop that moved next for 500 times and then I'd start reading the next 9
records from the database.
Is there no way to accomplish this task with ADO.Net? If there isn't, I
must be missing what's so great about Ado.Net. Does Whidbey address this?
Thanks for everyone's responses so far...
"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:LTJRlLh8DHA.1152@cpmsftngxa07.phx.gbl...
> 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: ShijuFrancis: "RE: Binding with a DataRelation"
- Previous message: wjer: "Way to loop code for inserting Checkboxlist values into DB?"
- In reply to: Kevin Yu [MSFT]: "RE: Best way to return a select number of rows?"
- Next in thread: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Reply: Kevin Yu [MSFT]: "Re: Best way to return a select number of rows?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|