locked
Duplicate insert conflict detection RRS feed

  • Question

  •  

    Hi,

     

    I am quite new to the synch framework, I have read quite a lot about it, as I need to create a multi client "OCA".

     

    Now I have a problem, and don't know if it is me that didn't quite get something, or if I am taking the wrong approche to my problem.

     

    I have different users that will be working offsite, updating the local cached databases that are then synched to a central server, either trough the company intranet or trough the internet. My problem is how to detect and solve the following conflict in a efficient manner:

     

     - Two users work at the same new client site and they both have to enter a new row in a "Company" table, lets call it "company A". then they work with new contacts in that company and so on resulting in new rows in other tables related to the "company A" row. Each row in the company table has a GUID as primary key, meaning it is unique, even if the two companies are the same.. and when the synchronization happens, no conflicts are detected. This means that I have a duplicate "Company A" in the database with all related tables that either have one GUID or the other.  Now in my design, I try to limit the cases where this scenario happens buy requiring server access to enter a new company. But that doesn't eliminate the problem. the risk is still there... so i would like to somehow do a check on a different column in the table, like the company name, to recognize duplicates and merge the GUID's, on synchronization (this can work for instrument serial numbers.. etc.. that are unique)

     

    Is there an efficient way to do this?

     

    I though about using natural keys.. but that creates more problems on cascading the changes accross the different clients etc..

     

    Thank you in advance.

     

    • Moved by Hengzhe Li Friday, April 22, 2011 7:42 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, June 2, 2008 1:34 PM

Answers

  •  

    if you cannot use the compnay name as the PK for the table, can you try to make it as UNIQUE index ? this should cause the second sync to fail when inserting the new row.

     

    thanks

    Yunwen

    Friday, June 6, 2008 11:46 PM
    Moderator

All replies

  •  

    if you cannot use the compnay name as the PK for the table, can you try to make it as UNIQUE index ? this should cause the second sync to fail when inserting the new row.

     

    thanks

    Yunwen

    Friday, June 6, 2008 11:46 PM
    Moderator

  • I have a simular problem. Im trying to sync a table where the primary key is a Guid. I have set an index on the table and in getting a conflict detected. The only problem is that the conflict im getting is an ErrorsOccurred. This only supply the client sync information and not the server information so i am not able to merge the results, or having the user selecting the result he wants to keep.

    The exception im getting is:
    Cannot insert duplicate key row in object 'dbo.Log' with unique index 'IX_ItemId_VersionId'.\r\nThe statement has been terminated.

    The table i have looks something like this:
    PK GUID LogId
    FK ItemId
    FK VersionId

    Is there a way to stop sync, but get some of the values returned from the syncronization so that i can update the database manualy, and then try to sync again? or is there a way to get the sync service to detect this conflict as a ClientInsertServerInsert conflict instead? because then i would have the information i need.

    (
    Im using SqlExpress2008, and vs2008.)

    Let me know if you need more information to answer my question.
    Thursday, December 11, 2008 5:30 PM