Find the differences between two datatables

  • Thread starter Thread starter thecolour
  • Start date Start date
T

thecolour

Dear all,

I have to perform a programatic reconciliation of two sets of data
which are based on the same schema. I thought a brilliant way to do
this would be to use the dataset.getchanges() method, and then write
the changes out as a diffgram using the dataset.writexml() method.

The way I am trying to do this involves:

1) creating a dataset
2) loading datatable1 into it
3) calling acceptchanges()
4) loading datatable2 into it
5) calling getchanges()
6) creating the diffgram by calling writexml()

However, I have found that even though the two datatables are based on
the same schema with the same primary key values, the getchanges()
method doesn't seem to be able to treat

Row
ID Textvalue
1 Test (from datatable1)
1 Test (from datatable2)

as equivalent, so even though the row data has not changed, the
getchanges() method returns the row as changed, seemingly because it
has been replaced with a rows from another datatable.

This is a problem, as I only want the getchanges() method to return
changes to the actual data.

Have I explained this clearly enough, and would someone please please
be good enough to give me some pointers?

Many thanks
Tom
 
Dear all,

I have to perform a programatic reconciliation of two sets of data
which are based on the same schema. I thought a brilliant way to do
this would be to use the dataset.getchanges() method, and then write
the changes out as a diffgram using the dataset.writexml() method.

The way I am trying to do this involves:

1) creating a dataset
2) loading datatable1 into it
3) calling acceptchanges()
4) loading datatable2 into it
5) calling getchanges()
6) creating the diffgram by calling writexml()

However, I have found that even though the two datatables are based on
the same schema with the same primary key values, the getchanges()
method doesn't seem to be able to treat

Row
ID Textvalue
1 Test (from datatable1)
1 Test (from datatable2)

as equivalent, so even though the row data has not changed, the
getchanges() method returns the row as changed, seemingly because it
has been replaced with a rows from another datatable.

This is a problem, as I only want the getchanges() method to return
changes to the actual data.

Have I explained this clearly enough, and would someone please please
be good enough to give me some pointers?

Many thanks
Tom

I have actually found out that the merge method does not perform the
required row state updates to make this approach valid.
 
I have actually found out that the merge method does not perform the
required row state updates to make this approach valid.

This is similar to something I was recently working on where I need to
aggregate offline data changes from different users (but only care
about records that have changed).

Have you considered temporarily replacing the PK with a (composite)
Pseudo Key consisting of the columns that can change, then doing a
merge. (NOte: You only do this with 'in memory' the dataset/table -
NOT the database version). You'll also need to reset the PK after the
merge.

This might work - however if you have many columns you may end up
defining the entire table (excluding the PK) as the new PseudoKey. If
you come up with a better approach, please post here.

Brendan
 
Back
Top