C# DataAdapter and DataSet with multiple table

Jake picture Jake · Jan 1, 2011 · Viewed 34.2k times · Source

I have read from many places that it is possible to fill a DataSet with multiple tables using a DataAdapter. It also does not say whether a single Update call can update all the tables in the DataSet.

Can someone help me figure out how this can be done?

It seems like there isn't any ( i tried finding online ) examples on how to do it except for one that changes the SelectCommand on the DataAdapter before the second fill. But I feel this method defeats the purpose of the DataAdapter.

From what I figure, perhaps a single DataAdapter can only handle a single database table and Update only works on that table. Hence a multi-table DataSet will require respective DataAdapters call their Update to fully update the DataSet. Is this the case?

Finally, will foreign key relations and contraints hold in a DataSet (cascade delete, cascade update) automatically?

Maybe a link to an example or tutorial might help. Many thanks!

Answer

Naveed picture Naveed · Jan 1, 2011

May be these article will help:

Following official articles also very useful information:

Look at the "Populating a DataSet from Multiple DataAdapters" section in above article.