0
votes

I have two DataTable with same schema and very similar data. One has data from web service, second from local XML file (data saved from last session).

What I want to do is:

  1. Merge() new data from service and old data from file
  2. GetChanges() to see which data has change since last session.
  3. Perform action for all new, modified and deleted rows.
  4. Save data to file.

I have problem in step one. When I merge two DataTable, I got exception that primary key already exists in DataTable. This is not behavior I need. In this case DataRow should be updated, not added.

Mayby someone know easy way to solve this problem. Thanks a lot.

1

1 Answers

1
votes

Article linked by Honza Kovář have an example. This code works fine and looks the same as my code. I found problem in typed dataset I created. I have made a mistake and set field to key, not to primary key.