Re: Tip on filling DataSet in C#



This is a common question so be sure to search the archives.
The default behavior of the TableAdapter assumes you're working with a home
database that can fit on a floppy. IMHO, it should encourage developers to
build parameter-based queries to return just the subset of table rows that
are needed. No, there is no built-in mechanism to page through a large table
like yours. However, most developers approach this problem by using
"boundary" parameters. For example, one type of boundary parameter sets a
global criteria for the query--as when you choose to search for Pizza stores
in a specific zip code. By forcing the user to limit the scope of the query,
you permit the DBMS to make an intelligent search and return an intelligent
(and small) rowset. If this approach returns a lot of Pizza stores (more
than will fit on a form or page), you'll want to limit the rows by using TOP
(if available) or other SQL that limits the total rows returned. To fetch
the next set of rows, include a parameter that specifies that the first row
should be the same as (or one higher than) the last row fetched based on an
indexed column.

All of these parameter-driven queries can be incorporated into the
TableAdapter by using the TableAdapter diagram page in VS. Right-click the
"Fill" and create a new query that includes the needed parameters. When you
invoke the Fill, you'll be prompted with Intellisense to provide the
parameter values.

I describe these techniques in depth in my book.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
-----------------------------------------------------------------------------------------------------------------------

"Martin Arvidsson" <yeahright@xxxxxx> wrote in message
news:OOyHWFS$GHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
Hi all gurus out there!

When i use the Wizard to create some fields from a table it creates, the
dataset, bindingsource and tableadapter.

Now for the problem. When i open that form in my program, it automaticly
fills the dataset with all the records in the table. In this case there is
over one milion records. It takes ages to fill the dataset and view the
form.

So i created a Fill procedure that only gets the first 1000. Now if the
customer want to search beond this record how can i do that, ie fill the
dataset with the next record from the table....

Alla in all, i just want to fill the dataset with x records, then fill x
record at a time when clicking next.

Any suggestions, links to a nice page describing this problem?

Regards
Martin





.



Relevant Pages

  • Re: changing a datasets contents
    ... Once you setup a query / table adapter with a "@Filter" ... on the form, when you "drag and drop" the fields on the form, go to the code, and look for the tableadapter. ... I need to be able to change the query via vb.net at run time ... My question is that the query that I build in the dataset wizard in my project, needs to now change its where clause. ...
    (microsoft.public.dotnet.languages.vb)
  • TableAdapter and ROW_NUMBER problem
    ... want to run a paged query within a TableAdapter. ... In the TableAdapter Query ... Configuration Wizard" I write the next query: ... if I run the query from within Microsoft SQL Server Management Studio ...
    (microsoft.public.dotnet.framework.aspnet)
  • TableAdapter and ROW_NUMBER problem
    ... want to run a paged query within a TableAdapter. ... In the TableAdapter Query ... Configuration Wizard" I write the next query: ... if I run the query from within Microsoft SQL Server Management Studio ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Select Value From Specific Table Column in TableAdapter
    ... I have a dataset in which a parameterized query returns the correct result ... set in the forms of a tableadapter and a bindingnavigator. ... "itemtype" column is so I can customize the information on the form. ...
    (microsoft.public.dotnet.languages.vb)
  • Add query with parameter to tableadapter ?
    ... I'm trying out the tableadapter in vb.net V2 framework. ... I now want to add a parameter to a query, right click myTableTableAdapter, ... "Specify a SQL Select Statement", which is preloaded with SELECT t_ID, ...
    (microsoft.public.dotnet.framework.adonet)