Proper use of Data Adapters

J

JD Kronicz

I am new to VS.net and I am trying to figure out how to
use data adapters and datasets. It seems that from what I
have read you typically use a data adapter to retrieve a
single table. Then multiple data adapters are used to
fill a single dataset and relations are defined to yield a
hierarchial structure.
I see that you can configure a data adapter to return more
than one table. Why not use a data adapter to return
multiple tables to a dataset instead of a seperate data
adapter for each data table?

I am also trying to figure out when you would use views or
stored procedures in the database as opposed to
constructing these same elements in a dataadapter.

Any thoughts on this topic would be greatly appreciated.
In addtion, any references would also be appreciated.

Thanks - JD
 
M

msnews.microsoft.com

It depends on what you are doing. If you separately update data, using the
built in .NET way, multiple adapters make it easier, as the Adapter Update
method can be fired to save changes.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
W

William \(Bill\) Vaughn

Yes, unfortunately the doc (and many examples) implies that you should
retrieve a single table with a DataAdapter (DA). While this is ok for
single-user applications with small tables, this approach falls apart
quickly as the number of user grows (past 1) and the number of rows to
retrieve increases past a few hundred. The DA is designed to work with
rowsets. The naming of the DataTable object is unfortunate--I wish they had
called it the "DataRowset" object instead. Generally, one creates a SELECT
query to return a focused set of rows (for example, all the honest lawyers
in your town) instead of the entire table. If you expect to use the DA
Update method on the rowset, you'll need a separate DA for each. Yes, a
single DataSet can hold many tables and each of the DAs can point to the
same DataSet.

I discuss this in detail in my book.

hth

--
____________________________________
Bill Vaughn
MVP, hRD
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.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top