With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

3.3. Determining the Differences in Data Between Two DataSet Objects

Problem

You have two DataSet objects
with the same schema but containing
different data and need to determine the difference between the data
in the two.

Solution

Compare the two DataSet objects with
the
GetDataSetDifference( )
method shown in this solution and return the differences between the
data as a DiffGram.

The sample code contains two event handlers and a single method:

Form.Load

Sets up the sample by creating two DataSet objects
each containing a different subset of records from the Categories
table from the Northwind sample database. The default view for each
table is bound to a data grid on the form.

Get Difference Button.Click

Simply calls GetDataSetDifference( ) when the user
clicks the button.

GetDataSetDifference( )

This method takes two DataSet objects with
identical schemas as arguments and returns a
DiffGram of the differences between the data in
the two.