title: ADO.NET - Updating Multiple DataTables
body: <p>So I have some code like this:</p>
  
  <pre><code>        DataSet dataSet = new DataSet();            
          DataTable dataTable1 = new DataTable("Table1");
          DataTable dataTable2 = new DataTable("Table2");
          DataTable dataTable3 = new DataTable("Table3");
          DataTable dataTable4 = new DataTable("Table4");
          dataSet.Tables.Add(dataTable1);
          dataSet.Tables.Add(dataTable2);
          dataSet.Tables.Add(dataTable3);
          dataSet.Tables.Add(dataTable4);
  
          SqlDataAdapter dataAdapter1 = new SqlDataAdapter("SELECT * FROM Table1 WHERE ID = 1", sqlConnection);
          SqlDataAdapter dataAdapter2 = new SqlDataAdapter("SELECT Column1, Column2, Column3 FROM Table2", sqlConnection);
          SqlDataAdapter dataAdapter3 = new SqlDataAdapter("SELECT Column1, Column2, Column3 FROM Table3", sqlConnection);
          SqlDataAdapter dataAdapter4 = new SqlDataAdapter("SELECT Column1, Column2, Column3 FROM Table4", sqlConnection);
  
          SqlCommandBuilder commandBuilder1 = new SqlCommandBuilder(dataAdapter1);
          SqlCommandBuilder commandBuilder2 = new SqlCommandBuilder(dataAdapter2);
          SqlCommandBuilder commandBuilder3 = new SqlCommandBuilder(dataAdapter3);
          SqlCommandBuilder commandBuilder4 = new SqlCommandBuilder(dataAdapter4);            
  
          dataAdapter1.Fill(dataTable1);
          dataAdapter2.FillSchema(dataTable2, SchemaType.Source);
          dataAdapter3.FillSchema(dataTable3, SchemaType.Source);
          dataAdapter4.FillSchema(dataTable4, SchemaType.Source);
  
          //do a bunch of code that updates the one row from Table1
          //and adds lots of new rows to Table2, Table3, Table4
  
          dataAdapter1.Update(dataTable1);
          dataAdapter2.Update(dataTable2);
          dataAdapter3.Update(dataTable3);
          dataAdapter4.Update(dataTable4);
          dataSet.AcceptChanges();
  </code></pre>
  
  <p>Is there anyway to make this a lot simpler?  What would happen if the computer crashed on the line after "dataAdapter2.Update(dataTable2);"?  I would like to be able to somehow use just one Update call to update everything.  Is that possible?</p>
  
  <p>Also, is this even the best way to do this? With "this" being creating a bunch of new rows in multiple tables depending on what is in one specific row in one specific table.</p>