How to compare DataTables?

M

Mika M

Hi!

I should retrieve DataTable of the source database and compare that with
the target database's DataTable. Only those lines in source database's
DataTable which has (new unknown) code that does not already exist in
target database's DataTable should add (ie. import) into target
database's DataTable.

Source database in MS Access, and target database is MS SQL Server.

Propably I have to create DataTables of the both database's tables
first, but how to continue? Of course I can compare lines between
datatables looping each line, but maybe DataTable objects has more
advanced features available to do this easy way.
 
C

Cor Ligthert

Mika,

In my opinion do you have a lot of approaches, you delete in your
dataadapter the update and delecte command (or not set it, that depends how
you make it) and than set the continue when there is an error, for me this
is a kind of rough way.

http://msdn.microsoft.com/library/d...ataadapterclasscontinueupdateonerrortopic.asp

You can first do a select with a very small dataset (only the primary keys)
however the same criteria as in your Access database.

Create clone dataset and than load the rows in the new table accoording the
selected dataset (do not remove from the original that goes in Net 1x to
slow).

Be aware not to use the acceptchanges is true in anyway.

Than you can update that created dataset.

Just some thoughts, I never had this problem.

Cor
 

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