DataTable::Merge Method
Assembly: System.Data (in System.Data.dll)
| Name | Description | |
|---|---|---|
![]() | Merge(DataTable^) | |
![]() | Merge(DataTable^, Boolean) | Merge the specified DataTable with the current DataTable, indicating whether to preserve changes in the current DataTable. |
![]() | Merge(DataTable^, Boolean, MissingSchemaAction) | Merge the specified DataTable with the current DataTable, indicating whether to preserve changes and how to handle missing schema in the current DataTable. |
The Merge method is used to merge two DataTable objects that have largely similar schemas. A merge is typically used on a client application to incorporate the latest changes from a data source into an existing DataTable. This allows the client application to have a refreshed DataTable with the latest data from the data source.
The merge operation takes into account only the original table, and the table to be merged. Child tables are not affected or included. If a table has one or more child tables, defined as part of a relationship, each child table must be merged individually.
The following console application demonstrates the behavior of the missingSchemaAction parameter of the Merge method. This example creates two versions of the same table, modifying the schema for the second version. The code then attempts to merge the second table into the first.
Note |
|---|
This example shows how to use one of the overloaded versions of Merge. For other examples that might be available, see the individual overload topics. |

