Sync framework no records being synced. RRS feed

  • Question

  • I've created a wpf client application that syncs with a sqlserver2005 database.  The client database is a local data cache that I created through visual studio 10.

    The production environment has been upgraded to sqlserver 2008.  I scripted the server database (with all triggers and stored procs) and created a new instance on the production server.  When I deploy my app, I changed the server connection string to point to the production database.  When I run my application, all the data from when I created the local data cache is there, but it doesn't synch with the server and no records are uploaded or downloaded...  I'm really struggling with this.

    I think I might be deploying my local compact sql server incorrectly... any help would be appreciated.



    Thursday, September 16, 2010 1:01 AM

All replies

  • try to do a dummy update on the rows in the client. when the client syncs, it will look for changes where the timestamp is greater than the last sent timestamp. If you havent made any changes on the client rows, it wont detect anything. The sync metadata in your scenario is only maintained in the client, not in the server. the client has no idea what's in the server. it only knows the anchor from the last upload. it doesnt know if the server is empty or not.


    Thursday, September 16, 2010 1:32 AM
  • I guess that's where I'm having problems.  I'm able to use my application essentially "disconnected".  I'm adding new rows and updating new records... I run the sync and nothing is uploaded to the server...  I close the application, open it up, and all the changes are still there, just on the client only.  If I run the application on my dev network, everything works perfectly.


    Is there a way to essentially put the client database in a state to think it's doing it's first synch?   Thanks for you reply.

    Thursday, September 16, 2010 1:43 AM
  • do a trace or step thru the code and check in the ChangesSelected event if its picking up the changes on the client.

    Then do a SQL Profiler trace on the server side to check if its applying anything and is failing for some reason. Also, look at the ApplyChangeFailed event.

    A change on the server side should not affect the way changes are selected on the client.

    this maybe a silly question, but can you verify that the connection string is indeed pointing to the new database instance, if i remember it right, the connection string is hardcoded in generated code of the Local Database Cache wizard.

    Thursday, September 16, 2010 2:04 AM
  • I'm essentially using the sync adapter that was created for me when I created the local database cache, so i'm not overly familiar with hooking into the ApplyChangeFailed event, or how I would do that without writing all custom adapters... is there a way I can do that with the sync code that's generated for me... (i'm not lazy, just massive time constraints)...

    I also ran a trace, and noticed that the sync is definitely hitting the server... but the last two parameters of the proc it's trying to run is @sync_last_received_anchor = null and @sync_new_received_anchor = null. 


    thanks again for any help.




    Thursday, September 16, 2010 3:06 AM
  • try this, assuming you used the wizard:

    var remoteProvider = (LocalDatabaseCache1ServerSyncProvider) syncAgent.RemoteProvider;

    remoteProvider.ApplyChangeFailed += remoteProvider_ApplyChangeFailed;

    then you'll have the event handler similar to this:

    static void remoteProvider_ApplyChangeFailed(object sender, ApplyChangeFailedEventArgs e)

    // check the conflict type in the event args
    // e.g. e.Conflict.ConflictType


    can you post a sample trace of the SQL hitting the server?

    Thursday, September 16, 2010 3:41 AM
  • exec sp_executesql N' SET FMTONLY OFF; SET NO_BROWSETABLE ON;SELECT [typeId], [description], [LastEditDate], [CreationDate] FROM dbo.VIPType WHERE ([CreationDate] > @sync_last_received_anchor AND [CreationDate] <= @sync_new_received_anchor)',N'@sync_last_received_anchor datetime,@sync_new_received_anchor datetime',@sync_last_received_anchor=NULL,@sync_new_received_anchor=NULL


    I'm not getting any conflicts....

    Thursday, September 16, 2010 3:13 PM
  • strange, if you have previously created the client db using the Local Database Cache, it should have a value for the last received anchor. even stranger that your new received anchor is also null.

    and this use to work on SQL 2005 right?


    Thursday, September 16, 2010 3:24 PM
  • Yea, I really can't figure this out and I feel like it shouldn't be this difficult.  So, I'll go through each step and see if i'm missing something.


    1.  I used the wizard to generate a local database cache, it created the .sdf and also synched it and filled it with data.

    2.  I used a sql server 2005 database on our server as the server database. 

    3.  On my local machine, when I run the application as a release or in debug, everything works fine.

    4.  the production environment is a small local area network with 1 server and 3 clients. 

    5.  the production server is running sql server 2008.  I fully scripted the 2005 database and ran it on the 2008 box recreating the database on the production server (I even restored a back up of the 2005 working one on the 2008 box just to make sure that everything was identical).

    6. I created a one click deployment

    7. I deployed the app to my client machines.

    8. I open the application, the original seeded data from when I ran the wizard is showing, but nothing gets synced.


    At this point, all I can think of is that the original local cache created by the wizard somehow is recognizing that the new server is different, and using a different serverId in the __sync subscriptions table and saying there is nothing to sync.


    Thursday, September 16, 2010 3:47 PM
  • have you checked that you deployed the right Sync Fx assemblies? i remember seeing a thread where __sync objects in the CE database are different based on the providers used.
    Thursday, September 16, 2010 4:36 PM
  • I decided to create a local sql 2008 database on my dev machine, create a local database cache from that, and then redeploy and see if the change from 2005 to 2008 was the difference... but when I made the new cache and ran my code,

    The specified change tracking operation is not supported. To carry out this operation on the table, disable the change tracking on the table, and enable the change tracking


    syncronization v1.0

    syncronization.data v1.0

    syncronization.data.server 1.0

    sycnronization.data.server.ce 3.5


    I tried changing the references to newer versions, but it always says there's conflicts.


    Thursday, September 16, 2010 7:08 PM
  • can you verify that the machines are all using the same version of SQL CE?
    Friday, September 17, 2010 12:58 AM