Working with DataSet Events
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.NET Framework Developer's Guide
Working with DataSet Events

The DataSet provides a MergeFailed event that will be 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 will be thrown and the MergeFailed event will be 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 custDS 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
[C#]
DataSet custDS = 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

Creating and Using DataSets | DataSet Class | MergeFailedEventArgs Class | PropertyChangedEventArgs Class

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View