Re: Best way to return a select number of rows?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jeff (jrendl_at_spammer.org)
Date: 02/13/04


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."
>



Relevant Pages

  • Re: FE database not showing new table added to BE database
    ... You should now see the missing table in your FE. ... My database has been split. ... BE is stored in shared folder on the server. ... I added it in the BE file, but when I run the FE, it's not showing up ...
    (comp.databases.ms-access)
  • Attach/Detach
    ... Posted this in programming but might be better off here... ... I'm trying to copy a database from one instance to another on a ... different server. ... Am I missing anything? ...
    (microsoft.public.sqlserver.setup)
  • Force error message when database is missing
    ... I have a FrontPage ASP file writing form data to an Access database on ... a different server. ... to return an error message if the database is missing, ...
    (microsoft.public.frontpage.programming)
  • Re: new "named colors"
    ... > your own color to the list, just remeber that the values are in INT ... afaict, X reads rgb.txt at startup, period. ... after that, the X server ... database of a _running_ X ...
    (comp.os.linux.x)
  • Web Page
    ... I have created a Web 'page' in MS Access based on a database. ... server to test them I cannot open the Web page, ... is not visible, only the header. ... What am I missing? ...
    (microsoft.public.access.dataaccess.pages)