Working with DataSet Events
The DataSet provides a MergeFailed event that is raised when the schema of the DataSet objects being merged are in conflict. For example, if the primary key columns of a table being merged differ between the tables in the two DataSet objects, an exception is thrown and the MergeFailed event is raised. The MergeFailedEventArgs passed to the MergeFailed event have a Conflict property that identifies the conflict in schema between the two DataSet objects, and a Table property that identifies the name of the table in conflict.
For information about other events available when working with a DataSet, see Working with DataTable Events and Working with DataAdapter Events.
The following code example adds the MergeFailed event to an event handler.
Dim workDS As DataSet = New DataSet
AddHandler workDS.MergeFailed, New MergeFailedEventHandler( _
AddressOf DataSetMergeFailed)
Private Shared Sub DataSetMergeFailed( _
sender As Object,args As MergeFailedEventArgs)
Console.WriteLine("Merge failed for table " & args.Table.TableName)
Console.WriteLine("Conflict = " & args.Conflict)
End Sub
DataSet workDS = new DataSet();
workDS.MergeFailed += new MergeFailedEventHandler(DataSetMergeFailed);
private static void DataSetMergeFailed(
object sender, MergeFailedEventArgs args)
{
Console.WriteLine("Merge failed for table " + args.Table.TableName);
Console.WriteLine("Conflict = " + args.Conflict);
}
See Also
Reference
DataSet Class
MergeFailedEventArgs Class
PropertyChangedEventArgs Class