How to avoid duplicates in keys? RRS feed

  • Question

  • I'm planning an applicaiton that will let outside salespeople do quotations and sales orders whiile disconnected in the field, then sync when they get back to the office, home, or anywhere with broadband. I want to build it in VS2008 vb.net using the Compact SQL and Sync Services.


    I'm hoping sync services has some magic that takes care of this automatically, but I haven't seen it yet.


    Let's assume my database will look a lot like the AdventureWorks sample. If a new SalesOrderID in the SalesOrderHeader table is generated in the field on multiple remote clients, and/or new orders are also generated by connected clients, won't there be duplicate SalesOrderIDs when they sync?


    I thought about making the EmployeeID+SalesOrderID the key, but the same employee could be on multiple machines at the same time. We need some SaleOrder or reference number that we can leave with the customer when we take the order in the field, that will be a consistent reference throughout the order process.


    Thanks for any suggestions or links that might help,


    • Moved by Max Wang_1983 Friday, April 22, 2011 9:33 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, November 30, 2007 3:16 PM

All replies

  • Okay, I did a little more searching and found a seciton in the help file called :Selecting an Appropriate Primary Key for a Distributed Environment (Synchronization Services) This awnswered my questions.


    One method was Keys That Include a Node Identifier. It mentioned a ClientID that is assigned by sync services. How can I pull this value in my vb.net code?

    Friday, November 30, 2007 5:14 PM
  • Hi Steve,


    The client Id propery is exposed on the SqlCeClientSyncProvider object.



    Friday, November 30, 2007 10:06 PM