Assuming that the schema of the dtJob
DataTable is the sum of the dtStock
and dtSpec
schemas you might want to look at the DataTable.Merge method to propagate the changes from dtJob
to the two other tables.
Here's an example:
dtStock.Merge(dtJob, preserveChanges: false, MissingSchemaAction.Ignore);
dtSpec.Merge(dtJob, preserveChanges: false, MissingSchemaAction.Ignore);
Note that in this sample I've used named arguments, which are only available in C# 4.0, in order to make the method call more readable.
Here's a more complete example:
var firstTable = new DataTable();
firstTable.Columns.Add(new DataColumn("FirstTableId", typeof(int)));
firstTable.Columns.Add(new DataColumn("FirstTableName", typeof(string)));
firstTable.Columns.Add(new DataColumn("SecondTableId", typeof(int)));
var secondTable = new DataTable();
secondTable.Columns.Add(new DataColumn("SecondTableId", typeof(int)));
secondTable.Columns.Add(new DataColumn("SecondTableName", typeof(string)));
var joinedTable = new DataTable();
joinedTable.Columns.Add(new DataColumn("FirstTableId", typeof(int)));
joinedTable.Columns.Add(new DataColumn("FirstTableName", typeof(string)));
joinedTable.Columns.Add(new DataColumn("SecondTableId", typeof(int)));
joinedTable.Columns.Add(new DataColumn("SecondTableName", typeof(string)));
joinedTable.Rows.Add(1, "FirstTableRow1", 1, "SecondTableRow1");
joinedTable.Rows.Add(2, "FirstTableRow2", 1, "SecondTableRow1");
joinedTable.Rows.Add(3, "FirstTableRow3", 2, "SecondTableRow2");
firstTable.Merge(joinedTable, false, MissingSchemaAction.Ignore);
secondTable.Merge(joinedTable, false, MissingSchemaAction.Ignore);
Related resources: