SQL2008 R2 to SQL CE 3.5 SP2 Sync Errors When Client NOT installed on Server RRS feed

  • Question

  • Hi,

    We have what I believe to be a standard set up on a server

    Windows Server 2008
    SQL Server 2008 R2
    Visual Studio 2010 Premium.

    We are building an online/ offline windows app using the Microsoft sync framework to synchronise data between the SQL 2008 R2 on the server and the client windosws app we are developing which is using SQL Compact Edition 3.5 SP2 to store the data locally.

    Currently we are only sending updates from the server to the client.

    We are using Visual Studio's "click once" technology to deploy the client app to the user's machines.

    The problem we are having is as follows.

    When we deploy the client app to the server so that client and server are running on the same machine, everything runs fine.

    When we deploy the app to any other machine the following occurs.

    If a new record is inserted in the server db, then the user clicks on the sync button within the client app, the client app receives the new record, it happily gets added into the local db and then displays the new record in the windows form.

    However,for updates or deletes on the server the following ERROR occurs.

    The user clicks the sync button, the client app reports that sync updates/deletes have been received but then these updates are NOT written to the local cache db.

    Any help / ideas will be greatly  appreciated.

    Friday, April 1, 2011 10:02 AM

All replies

  • try subscribing to the ApplyChangeFailed event on the client app and check if there are any error or conflict being detected.
    Friday, April 1, 2011 10:08 AM
  • Many thanks JuneT

    The problem I am having is that my provider does not seem to support the ApplyChangeFailed event.

    VS2010 is using Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider

    Can you give me any pointers ?

    I have been looking at the following article




    Friday, April 1, 2011 10:33 AM
  • Hi Rob,

    am not sure what you mean by your provider not supporting the ApplyChangeFailed event. afaik, its available on both offline and collaboration/peer to peer providers.

    are you using the SqlSyncProvider/SqlCeSyncProvider or the the SqlCeClientSyncProvider/DbServerSyncProvider?

    here's the other link if your using the offline providers: http://msdn.microsoft.com/en-us/library/bb725997.aspx

    can you clarify?



    Friday, April 1, 2011 10:46 AM
  • Hi Junet,

    I had a "newbie" moment.

    Got some error logging code in place.

    An error is being thrown during Sync Stage: ApplyingUpdates.

    Conflict Type: ClientUpdateServerUpdate.

    Just to be clear, we have not made any update to the client data.

    Hope you can help

    Kind regards




    • Edited by Rob Nugent Friday, April 1, 2011 12:20 PM
    Friday, April 1, 2011 11:30 AM
  • I should have also said that in the .sync file the table has the following property set.




    Friday, April 1, 2011 11:33 AM
  • can you confirm if your sync is downloading all rows again or only the updated ones?

    are you using a timestamp or a datetime column for retrieving changes?

    the conflict is actually fired when Sync Fx tries to update the row and the number of rows affected is zero which means that the operation has failed.

    you can take a look at the conflicting rows to investigate whats causing to fail on updating the client.


    Friday, April 1, 2011 1:07 PM
  • We are using the "New and incremental changes after first sync" option

    Can you tell me how  and where I identify the name of the column that is used to identify which records need to be synced?

    One thing I have discovered is that it is only ever the first update on any given record that fails. If I force it through, any subsequent updates made to that record occur without any errors being thrown.

    Many thanks once again.


    Friday, April 1, 2011 3:28 PM
  • you might want to run SQL Profiler to see the select changes query being fired to query the first update. when you configure local database cache, there is an option to generate the sql scripts, you'll see there the change tracking columns being added
    Sunday, April 3, 2011 1:25 AM
  • Hi Again,

    I have played around with the SQL Profiler and all looks fine to me.

    I have also been debugging the ApplyChangeFailedEvent to see if there was anything there.

    There is a lot of info please see below.

    All I am doing is updating the "Name" field on the sever from  "rob 1716" to "rob 1716 18"

    I used the Dataset Visualiser to look at the data in




                       Id(key)           Name                Modified Date                     Creation Date
    Server            13                rob 1716  18      07/04/2011 11:03:39         05/04/2011 16:30:02
    Client             13                rob 1716           05/04/2011 16:30:02         05/04/2011 16:30:02

    I would say that all looks well !

    Any more ideas?

    Kind regards





    Thursday, April 7, 2011 11:27 AM
  • was the update done immediately after your first sync? i noticed their is a big gap in the modified date column.

     can you try the steps for Removing Server Tracking Columns from Synchronization Commands from this link http://msdn.microsoft.com/en-us/library/cc714035.aspx even if your doing DownloadOnly sync?

    Thursday, April 7, 2011 3:07 PM
  • With regard to

    --> was the update done immediately after your first sync?

    How does the app know it is it's first sync - should I see some unique behaviour?

    When I publish the app using one click - it publishes the CE database with whatever records were in at the time of setting up the sync relationship.

    So it seems to me that first sync is no different to any subsequent syncs.

    Is there a property I can check ?


    Thursday, April 7, 2011 4:00 PM
  • What are the steps to deploy to a different machine? Will the Ce database contain some existing data?


    Thursday, April 7, 2011 11:52 PM
  • Hi Jin,

    We are using the VS2010 publish wizard, choosing the option to make the application available offline as well as online.

    Because we have been doing sync testing inside visual studio the CE database that is part of the solution contains data. This then gets deployed to other machines when we do the install.

    Is it best practise to deploy an empty DB ??

    Kind regards


    Friday, April 8, 2011 10:23 AM
  • The data existing in the DB may have caused those conflicts for you. If it's possible to deploy a empty db, it may solve your problem, otherwise, you can consider handling the initial conflicts.

    Friday, April 8, 2011 5:31 PM