tags:

views:

377

answers:

1

I have two datasets each with one data table pulled from different sources and I need to know if there are any differences in the data contained in the data tables. I'm trying to avoid looping and comparing each individual record or column, although there may be no other way. All I need to know is if there is a difference in the data, I do not need to know the details of any difference.

I have tried the below code, but it appears that dataset.Merge does not update rowstatus so dataset.HasChanges() always returns false. Any help is appreciated:

var currentDataSet = GetSomeData();
var historicalDataSet = GetSomeHistoricalData();

historicalDataSet.Merge(currentDataSet);

if (historicalDataSet.HasChanges()) DoSomeStuff();
+2  A: 

I don't know of any built-in support for this and I wouldn't expect it either. So you'll have to do this by yourself in some way.

The most obvious way would be a brute force, table by table and row by row approach.

If you can rely on certain factors to be the same, ie exactly the same naming, ordering of records etc then you could test if saving both as XML and comparing the results might be an efficient trick.

Henk Holterman
Yes, that is the ticket. In this case, schema and order of records are guaranteed, so this works perfectly. Should have thought of it myself! Thanks.
JasonS