NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataSet.Merge (DataSet, Boolean, MissingSchemaAction)

Merges this DataSet into a specified DataSet preserving changes according to the specified argument, and handling an incompatible schema according to the specified argument.

[Visual Basic]
Overloads Public Sub Merge( _
   ByVal dataSet As DataSet, _
   ByVal preserveChanges As Boolean, _
   ByVal missingSchemaAction As MissingSchemaAction _
)
[C#]
public void Merge(
   DataSet dataSet,
   bool preserveChanges,
   MissingSchemaAction missingSchemaAction
);
[C++]
public: void Merge(
   DataSet* dataSet,
   bool preserveChanges,
   MissingSchemaAction missingSchemaAction
);
[JScript]
public function Merge(
   dataSet : DataSet,
   preserveChanges : Boolean,
   missingSchemaAction : MissingSchemaAction
);

Parameters

dataSet
The DataSet whose data and schema will be merged.
preserveChanges
A value indicating whether changes in the current (target) DataSet should be maintained. true, if changes should be maintained; otherwise, false.
missingSchemaAction
One of the MissingSchemaAction values that specify what to do with an incompatible schema. Possible values include Add (for example, add a column), Ignore, or Error.

Exceptions

Exception Type Condition
ArgumentNullException The dataSet is a null reference (in Visual Basic Nothing).

Remarks

The Merge method is typically called after invoking the GetChanges method, which returns a DataSet optimized for merging.

To facilitate explanation of the Merge method, we use "target" to signify the current DataSet, and "source" to name the second (parameter) DataSet.

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.

If the source DataSet originated from a call to GetChanges on the target DataSet, a different matching procedure is employed. The source DataSet rows are matched up with the target rows they were cloned from. Once a match is found, original values in the target rows are updated with values from the source rows, while the changed values remain the same.

During a merge, constraints are disabled. If any constraints can't be enabled at the end of merge, an InvalidConstraintException is thrown and the data is kept with the constraints disabled.

See Also

DataSet Class | DataSet Members | System.Data Namespace | DataSet.Merge Overload List