Merges this DataTable into a specified DataTable. with a value to preserve changes made to the target, and a value to deal with missing schemas.
[Visual Basic] Overloads Public Sub Merge( _ ByVal table As DataTable, _ ByVal preserveChanges As Boolean, _ ByVal missingSchemaAction As MissingSchemaAction _ ) [C#] public void Merge( DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction ); [C++] public: void Merge( DataTable* table, bool preserveChanges, MissingSchemaAction missingSchemaAction ); [JScript] public function Merge( table : DataTable, preserveChanges : Boolean, missingSchemaAction : MissingSchemaAction );
Exception Type | Condition |
---|---|
ArgumentNullException | The dataSet is a null reference (in Visual Basic Nothing). |
Merges the specified DataTable (the source) into the current DataSet (the target). An attempt is made to locate the source DataTable in this DataSet.
If missingSchemaAction is set to Add, and the source table is missing in the target it will be added. If set to Ignore, source data from the missing table is ignored. If set to Error, an error will be thrown.
When the Merge method is called, the schemas of the two DataSet objects are compared. If the source DataSet contains schema elements that are missing in the target, the schema elements are added to the target. The data is then merged. When merging rows that have a DataRowState value of Unchanged, Modified, or Deleted source rows, the source's primary key is used to search for target rows that have the same primary key values. When merging New source rows, the new primary key value is used to search for target rows that are also New and have matching new primary keys.
DataSet Class | DataSet Members | System.Data Namespace | DataSet.Merge Overload List