C# Example: DataSet uses spS?

D

Dick Bridges

I've found 742 claims that it can be done - including Microsoft® ADO.NET
(Core Reference). On the other hand, I can't find the rules/form/format for
the spS or any but the most trivial examples.

Anyone know where I can find an example that shows how, for example, the
NorthWinds db Customer, Orders and Order Detail tables would be used to fill
*ONE* DataSet from *ONE* sp (i.e., 3 parameterized SELECT...); various rows
added, deleted and updated; and the spS that would be used to perform those
operations?

TIA
 
W

William \(Bill\) Vaughn

Sure it can be done. However, most of our examples are pretty generic--even
the ones from my C# book. The solutions we're talking about create three
DataAdapters--one for each table to do the updates. Most of the code can be
created by the Data Adapter Configuration Wizard. One of these DataAdapters
can be used to generate the DataSet tables by using a compound SELECT
statement that returns appropriate rows (the problem is, the DACW's query
builder does not understand multiple SELECTs) so you'll have to generate the
UpdateCommand, InsertCommand and DeleteCommand objects yourself for each of
the DataAdapters. This is not that hard since you're using SPs. Next, build
the relationships between the DataTables returned. When it's time to update
the data, use a DataView to get the new parent row(s) (the Customers) and
use the DataAdapter that points to the Customers table to execute a
parameter-based SP to INSERT the rows. Next, add, change and delete the
child rows using the appropriate DataAdapters.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________
 
D

Dick Bridges

IIUC, I can use a single DataAdapter with a compound SELECT to Fill() a
DataSet with multiple tables, but the update requires that I create one
DataAdapter for each table? Doesn't seem that it would have been all that
more difficult to have given the DataAdapter the ability to map DataSet
table names to to the appropriate commands (update, insert, delete). Oh
well.

Thanks for the response.
 

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