locked
Simple Data Sync Question - Problem with Sync RRS feed

  • Question

  • Hi There,

    I have purchased a book (APress - Pro Sync Framework), and am following the steps to create an offline database using Visual Studio 2008.

    The actual process to create it is fine, it creates a local SQL Compact Edition 3.5 database, and the first sync works perfectly.

    The problem I have is I go into my SQL Server 2005 (build 9.00.1406), and change a record. I make sure that the "modified date" is updated to the current date and time, which it is. Then I run a .synchronize() from a button in my Windows Forms application, and it tells me that no changes have been downloaded. I checked in debug mode, and all the properties like TotalChangesDownloaded, DownloadChangesFailed, etc, are zero.

    So, no errors, but the sync does not work either. All I did was use the "LocalDatabaseCache" wizard, and I chose a bunch of tables and set the created date and last modified date to the existing fields which contain that information.

    Your help is greatly appreciated, I'm bashing my head against a wall here.

    Thanks in advance!!

    • Moved by Hengzhe Li Friday, April 22, 2011 2:11 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, June 1, 2009 5:46 AM

Answers

  • Ensure that your triggers that are updating the LastEditDate column and the SelectNewAnchorCommand are consistent in that both are using GETUTCDATE(). 

    • Marked as answer by Edgeman Sunday, June 7, 2009 9:57 PM
    Friday, June 5, 2009 4:05 PM

All replies

  • Edgeman-

    How are you updating the row?  Can you confirm that the change has been committed to the database?  Once you have confirmed that, could you run the SQL Profiler to see what query is being run to enumerate changes?  See if running that query in Management Studio produces different results. 

    Thanks-
    Phil
    Tuesday, June 2, 2009 6:19 PM
  • Hi there!

    What I was doing was manually creating a row in the table, using SQL Management Studio 2005. I made sure, of course, that the date & time stamps were set correctly for the created date and last modified date.

    The weird thing is that when I wait a day the sync picks up the new record, it just won't pick it up straight away. Using profiler a day after I added the record it syncs perfectly, and here is the SQL Profiler entry for the successful sync:
    exec sp_executesql N'SELECT [ID], [StateID], [UserID], [dbt_created], [dbt_modified], [dbt_no], [dbt_name], [dbt_postadr0], [dbt_postadr1], [dbt_postadr2], [dbt_crossstreet], [dbt_postpc], [dbt_phone], [dbt_fax], [dbt_mobile], [dbt_phone2], [dbt_contsal], [dbt_contfirst], [dbt_contact], [dbt_class], [dbt_accountNo], [dbt_abn], [dbt_status], [dbt_accopen], [dbt_internet], [dbt_salesman], [CreatedDate], [LastModified] FROM dbo.tblDebtors WHERE ([CreatedDate] > @sync_last_received_anchor AND [CreatedDate] <= @sync_new_received_anchor)',N'@sync_last_received_anchor datetime,@sync_new_received_anchor datetime',@sync_last_received_anchor='2009-06-04 04:13:40:420',@sync_new_received_anchor='2009-06-04 23:07:21:800'

    Then I added another record in this table, and after 5 minutes ran another sync. Below is the new sync. I think I can see now why it is failing. The UTC date is in the past (by 10 hours - I'm in the +10 timezone):
    exec sp_executesql N'SELECT [ID], [StateID], [UserID], [dbt_created], [dbt_modified], [dbt_no], [dbt_name], [dbt_postadr0], [dbt_postadr1], [dbt_postadr2], [dbt_crossstreet], [dbt_postpc], [dbt_phone], [dbt_fax], [dbt_mobile], [dbt_phone2], [dbt_contsal], [dbt_contfirst], [dbt_contact], [dbt_class], [dbt_accountNo], [dbt_abn], [dbt_status], [dbt_accopen], [dbt_internet], [dbt_salesman], [CreatedDate], [LastModified] FROM dbo.tblDebtors WHERE ([CreatedDate] > @sync_last_received_anchor AND [CreatedDate] <= @sync_new_received_anchor)',N'@sync_last_received_anchor datetime,@sync_new_received_anchor datetime',@sync_last_received_anchor='2009-06-04 23:17:28:777',@sync_new_received_anchor='2009-06-04 23:18:09:837'


    So, my question then becomes, can I change the "GetUTCDate" code in the files that the sync wizard created to say "GetDate" instead? Or is there something I should change elsewhere?


    Thanks in advance!

    Thursday, June 4, 2009 11:20 PM
  • Ensure that your triggers that are updating the LastEditDate column and the SelectNewAnchorCommand are consistent in that both are using GETUTCDATE(). 

    • Marked as answer by Edgeman Sunday, June 7, 2009 9:57 PM
    Friday, June 5, 2009 4:05 PM
  • Ensure that your triggers that are updating the LastEditDate column and the SelectNewAnchorCommand are consistent in that both are using GETUTCDATE(). 


    Hi,

    I am new with data sink.Based on some given sample i created local data cache and added Employee table.
    now i have local( .SDF) file and Server database.I want to send local records from .sdf  to server databsse.So i used sync direction UploadOnly.
    Then i inseted some new records in local sdf file they are sync properly.But when i changed some record in sdf file then click sync button.It is not
    updated in server.I used standared example.Only diff is i am directly changing record in local sdf file not fro windows form.

    plz send any sugestions..

    thanks..
    satya

    Monday, August 3, 2009 7:40 AM