C # DataAdapter and DataSet with multiple tables

I read from many places that you can populate a DataSet with multiple tables using the DataAdapter. He also does not say whether one call to Update can update all tables in a DataSet.

Can someone help me figure out how to do this?

There seems to be no (I was trying to find online) examples of how to do this, except for one that modifies the SelectCommand in the DataAdapter before the second popup. But I believe that this method defeats the purpose of the DataAdapter.

From what I think, it is possible that one DataAdapter can process only one database table, and Update only works in this table. Consequently, a multitasking DataSet will require the corresponding DataAdapters to invoke their update to fully update the DataSet. Is that the case?

Finally, will external relationships and foreign key constraints be stored automatically in the DataSet (cascading deletion, cascading update)?

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

+5
source share
2 answers

Maybe this article will help:

After the official articles also very useful information:

See the section “Populating a Multiple Dataset” in the next article.

+6
source
  • , , .

  • " " , , "" . , , .

    public void SaveWithManager()
    {
    DataSet1TableAdapters.TableAdapterManager mgr1 = new DataSet1TableAdapters.TableAdapterManager();
    DataSet1TableAdapters.Table1TableAdapter taTbl1 = new DataSet1TableAdapters.Table1TableAdapter();
    DataSet1TableAdapters.Table2TableAdapter taTbl2 = new DataSet1TableAdapters.Table2TableAdapter();
    
    
    mgr1.Table1TableAdapter = taTbl1;
    mgr1.Table2TableAdapter = taTbl2;
    mgr1.UpdateOrder = DataSet1TableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete; 
    mgr1.UpdateAll(your dataset);
    

    }

  • , . . ( )

+5

All Articles