database initialization and first sync RRS feed

  • Question

  • Hi guys,

    I have a SQL CE database that is generated on the PC and then is installed on the PDA. (It doesn't work to create it on the first sync because of the size)

    Before the FIRST synchronization I use this code to enable change tracking:

    using (SqlCeConnection con = new SqlCeConnection("Data Source = " + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\FleetCheck2010.sdf")))
        System.Data.SqlServerCe.SqlCeChangeTracking ct = new SqlCeChangeTracking(con);
        ct.EnableTracking("Tyre", TrackingKeyType.PrimaryKey, TrackingOptions.All);

    Everything fine here.

    But at the first sync I get an error:

    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.

    Even if I try to close the app and then start again I get the same message. I also did a dummy update on the rows of the Tyre table, as I read on other treads. Still no change. Seems that  ct.EnableTracking("Tyre", TrackingKeyType.PrimaryKey, TrackingOptions.All); doesn't do a correct "enable change tracking" on the table.

    Any sugestions?


    PS. I use SQL CE 3.5SP2, ADO.NET Sync Services, VS2008 









    Wednesday, August 18, 2010 1:23 PM

All replies

  • I have this installed and now I also installed this hotfix: (http://hotfixv4.microsoft.com/Sync%20Framework/latest/973058/01.00.1506.00/free/401121_ENU_i386_zip.exe )

    No results yet.

    Wednesday, August 18, 2010 2:59 PM
  • I checked the references I have in my project:

    • C:\Program Files (x86)\Microsoft Synchronization Services\ADO.NET\v1.0\Devices\Microsoft.Synchronization.Data.dll Runtime Version : v2.0.50727 Version : 1.0.6000.0
    • C:\Program Files (x86)\Microsoft Synchronization Services\ADO.NET\v1.0\Devices\Microsoft.Synchronization.Data.SqlServerCe.dll Runtime Version: v2.0.50727 Version : 3.5.6000.0
    Are those the correct versions of V1 SP1 ?
    Wednesday, August 18, 2010 3:24 PM
  • on another note, why don't you just let Sync Fx enable the Change Tracking? Any specific reason why you're enabling the Change Tracking yourself?
    Thursday, August 19, 2010 2:14 AM
  • The reason why I enable change tracking myself is because I generate the database on the server side with custom SQL code, not with the sync framework. I do this because I apply complex filtering which are not easy to add to the generated selectincremental statements in sync generated code. I think there are some other steps to be performed beside enabling change tracking on the SQL CE before it will actually sync. How does it know the rows version and which rows have to be synced first time?
    Thursday, August 19, 2010 7:39 AM
  • it doesnt know which rows specifically, in the offline providers, it checks the anchors (last received and last sent). in the peer-to-peer providers, it checks the sync knowledge.

    in your case for example, assuming your SQL CE is newly provisioned, it's empty and its last received anchor is empty as well, so the query on the server will be all rows whose version (timestamp)  are greater than the last received anchor. on subsequent syncs, it will only retrieve rows that are greater than the last received anchor.

    i forgot to ask, is th exception thrown on the device itself? or just on the desktop?

    Thursday, August 19, 2010 8:43 AM
  • The exception is on the device at first sync. I can probably set the anchors values before the first sync like this:
     ClientSyncProvider sqlCeProvider;
                sqlCeProvider = (ClientSyncProvider)syncAgent.LocalProvider;
    sqlCeProvider.SetTableReceivedAnchor(TableName, new SyncAnchor....);

    But how can I find the correct anchor values? Is there any other approach to this problem?

    Thanks JuneT

    Thursday, August 19, 2010 12:21 PM
  • is your SQL CE on the Device on SP2 as well?
    Thursday, August 19, 2010 2:00 PM
  • Yes, I have SQL CE 3.5 SP2 on device.
    Thursday, August 19, 2010 3:12 PM
  • hi Radu,

    have you had any progress on this one?

    Monday, August 23, 2010 8:21 AM
  • I was away for a few days, but the problem is not yet fixed. I will replay when I have some progress.
    Thursday, August 26, 2010 3:25 PM