How to resolve conflict in case of unique key constraint while running synchronization RRS feed

  • Question

  • Hi All,

    I am using Microsoft sync framework collaborative offline scenario for syncing two databases. Here SqlExpressClientSyncProvider is being used for client sync provider and DbServerSyncProvider for Server sync provider. It works perfectly fine. Problem here I am getting when we have conflict data.

    Lets say one example we have one table with one column contains the unique data.


    ID     Name   AccountNo

    Here in above table ID is a primary key and AccountNo is unique Key. So in the server we have one row with some data, and in client another row with data with the same AccountNo as we have in the server. When we run synchronization it gives error of Unique key validation error.

    Here I want to handle like this, at first when it gives the Unique key validation error, it will show it to the user. I want to use ApplyAction.RetryNextSync action to keep the changed data from the server next sync so that next time user can make required changes to avoid the error and run the synchronization. I had used this ApplyAction to my code, but it seems not be working. Do you any idea why it is not working or do you have any alternative method to resolve this type of error/conflict, so that we will just have the change from server in case of error.


    Thursday, June 24, 2010 8:11 PM

All replies

  • RetryNextSync  is only valid for the peer-to-peer/collaboration synchronization. SQLExpressClientSyncProvider is an offline provider.

    You may want to modify the insert statement to check if the row exists. if it exists, do an update overwriting the client row with the server row. if it doesnt exists, just do a regular insert.

    • Proposed as answer by realtn Saturday, June 26, 2010 4:39 PM
    Friday, June 25, 2010 3:33 PM