Modified or new records

T

T Cordon

How can I compare 2 datasets form 2 completely identical tables in 2
different Databases and get only those records that have changed in one of
the DB's or are new?

Thanks
 
W

William Ryan eMVP

Use the primary key and loop through value by value and compare the values
of the row, column by column to get the changed ones. You can use a similar
approach to find new ones, sort on the PK and then

IsNul = (dt1.rows[PkColumn] != dt2.Rows[PkColumn] )

You'll obviously need to cast each to the respective type but the logic is
essentially the same. Or you could build a string of all of the values from
Table one and fire a sql statement with Not In(alloftheValues) and vice
versa..

This is probably much better suited to being handled server side with SQL
Though if at all possible.
 
T

T Cordon

Is there any other way to compare datasets?

William Ryan eMVP said:
Use the primary key and loop through value by value and compare the values
of the row, column by column to get the changed ones. You can use a similar
approach to find new ones, sort on the PK and then

IsNul = (dt1.rows[PkColumn] != dt2.Rows[PkColumn] )

You'll obviously need to cast each to the respective type but the logic is
essentially the same. Or you could build a string of all of the values from
Table one and fire a sql statement with Not In(alloftheValues) and vice
versa..

This is probably much better suited to being handled server side with SQL
Though if at all possible.
T Cordon said:
How can I compare 2 datasets form 2 completely identical tables in 2
different Databases and get only those records that have changed in one of
the DB's or are new?

Thanks
 
W

William Ryan eMVP

Other than rolling your own Compare method, I really don't think so.
T Cordon said:
Is there any other way to compare datasets?

William Ryan eMVP said:
Use the primary key and loop through value by value and compare the values
of the row, column by column to get the changed ones. You can use a similar
approach to find new ones, sort on the PK and then

IsNul = (dt1.rows[PkColumn] != dt2.Rows[PkColumn] )

You'll obviously need to cast each to the respective type but the logic is
essentially the same. Or you could build a string of all of the values from
Table one and fire a sql statement with Not In(alloftheValues) and vice
versa..

This is probably much better suited to being handled server side with SQL
Though if at all possible.
T Cordon said:
How can I compare 2 datasets form 2 completely identical tables in 2
different Databases and get only those records that have changed in
one
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top