locked
Sync not working - Problem in Database Timestamp RRS feed

  • Question

  • Hi All.

    I am developing a Application which uses microsoft sync services to sync data between Server DB and Client DB.
    I have a Server DB which has records in it. Initially my client DB will be Blank. The time stamp of Server DB is very big(3468000).The time stamp of Client Db is 2000 as it is a blank.
    I am not doing actuall sync when i download rows from server to client db. I am just doing SQLBulkCopy that manually fetches the rows from the server DB and inserts in the client DB

    Case 1:(Inserting server's create_timestamp value)

    When doing manual insertion i am taking the server's create_timestamp value of each row and inserting the same in my Client DB
    In this case when i do some changes to the records at the client side and do Sync(bidirectional sync),the changes made at the client side are not getting reflected to Server side because of the time stamp problem. As the Server timestamp is huge the incr_updates procedure is not fetching the updated rows. It is not returning any rows.


    Case 2:(Not Inserting server's create_timestamp value)

    In this case the server's create_timestamp value is not fetched. Create_timestamp values are generated at the client DB upon inserting rows from server to client dB.
    In this scenario changes done at the client Db are getting reflected at server,but the problem is conflict is not detected.


    Please advice me on how to solve this issue.
    Thanks in Advance.
    • Moved by Hengzhe Li Friday, April 22, 2011 3:10 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, June 1, 2009 6:01 AM

Answers

All replies

  • Hi,

    I assume that both of your Server and Client DB are SQL Server, and you are using the DbSyncProvider for the sync. if you use TSQL query to directly copy rows from one DB to another, there is no way to fix up the change tracking table to avoid initial sync. Sync Services ADO.Net peer provider is built on top of the Microsoft Sync Framework, it uses Knowledge to remember the sync history.

    The "Case 2" should work for you case. You can register OnChangeFailed callback and handle insert-insert conflict in the callback method.  

    Please let me know if my guess to your scenario is right. If not, please share me more details.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, June 2, 2009 12:23 AM
    Moderator
  • Hi Dong Cao,

    Thanks for your comments.

    If i use the second method(Case 2) is it possible to detect Conflict? If so, how to do it.

    Please give me some idea.

    Thanks in Advance.
    Tuesday, June 2, 2009 4:17 AM
  • One more thing... Is it possible to do criteria based sync?  Say i have 100 rows in a table, i want to sync only 5 rows. Is it possible?

    Thanks in Advance
    Tuesday, June 2, 2009 4:19 AM
  • One more thing... Is it possible to do criteria based sync?  Say i have 100 rows in a table, i want to sync only 5 rows. Is it possible?

    Thanks in Advance

    Have a look here: http://msdn.microsoft.com/en-us/library/bb726003.aspx


    Tuesday, June 2, 2009 3:17 PM
  • Hi,

    When there are conflicts or errors (such as PK voilation for insert-insert same PK case) during the sync, a OnChangeFailed event will be raised for each conflict or error record. You can set your apply action to resolve it. More details can be found in: http://msdn.microsoft.com/en-us/library/cc761628.aspx

    If you need a sample, you can install SyncSDK.msi, and look for sample: SharingAppDemo-Conflicts. Here is a link for the samples: http://msdn.microsoft.com/en-us/library/bb902841.aspx

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, June 2, 2009 8:30 PM
    Moderator