tags:

views:

38

answers:

1

Hi!

I have a dataset which has modified, inserted and deleted rows. I send the dataset.GetChanges to my MiddleTier which in turn sends it to a server that updates the database. I use GetChanges so I send over as few rows as possible.

The server updates, inserts and deletes rows just fine and sends back the updated dataset which I then merge with my local dataset. The problem is that I get duplicated added/modified rows when the primary keys do not match. So I guess I want to call RejectChanges after the merge which would remove all changes left (this would be duplicates). The problem then is that all deleted rows are still left in the dataset. The merge does not remove deleted rows, I need to call AcceptChanges to do this. So I need to do both Accept and RejectChanges but it's not possible.

Is there a good way to do this? Any suggestions on how to solve this in the best way possible?

Thanks!

+1  A: 

If you do AcceptChanges on the dataset before sending changes to the middle tier dataset should take care of itself (i.e. update, remove, add). this way u don't need to have to merge changes as you dataset is already updated.

You may also need to consider what should happen if and when those changes to server fail.

Check out MSDN article DataSet:AcceptChanges Method

TheOCD
The problem is that if I do AcceptChanges with no merge, I do not get the updated data in my local dataset (keys and stuff that is assigned in the database).
Karl Trumstedt