Handling Data Conflicts in the Microsoft Sync Framework
Example 1: ClientUpdateServerUpdate
In this example, we update the row with CustomerId of 2 in both the server and the client and then attempt to re- sync. On the server, we change the FirstName field to Chad. On the client, we change the FavoriteNumber field to 5. We get a ClientUpdateServerUpdate on the server SyncProvider:
Click here for larger image
Listing 1.3 ClientUpdateServerUpdate conflict on the server
If we choose Continue, the server changes "win" and the client's change is lost:
Click here for larger image
Listing 1.4 ClientUpdateServerUpdate conflict on the server with ApplyAction.Continue
If we choose RetryApplyingRow instead, the error is re- thrown because we have not made any changes to the data, so we are just presented with our conflict resolution form again.
If we choose RetryWithForceWrite, the client "wins" and the server changes are lost:
Click here for larger image
Listing 1.5 ClientUpdateServerUpdate conflict on the server with ApplyAction.RetryWithForceWrite
Example 2: ClientInsertServerInsert
In this example, we insert a new row into the server that gets a CustomerId (primary key) of 3. We also insert a new row into the client that gets a CustomerId (primary key) of 3.
Click here for larger image
Listing 1.6 Inserting new rows on both the client and the server
Now, when we try to synchronize, we get a ClientInsertServerInsert conflict on the server SyncProvider:

Click here for larger image
Listing 1.7 ClientInsertServerInsert conflict on the server
Page 3 of 4
This article was originally published on April 23, 2009