Rod
Rod

Reputation: 15423

datatable compare

I have a DataTable dtOld with records from database.

I have a DataTable dtNew with new records to be written to the database.

Can someone please help with the best way to send the new DataTable dtNew to the database without records that already exist in the dtOld DataTable?

thanks, rodchar

Upvotes: 0

Views: 383

Answers (1)

Andy West
Andy West

Reputation: 12499

Rather than maintain two separate DataTables, it might be easier to use the technique demonstrated here:

http://msdn.microsoft.com/en-us/library/xzb1zw3x%28VS.80%29.aspx

You can use a DataAdapter to update the database with records that have a particular row state (added, for instance).

Upvotes: 1

Related Questions