_tracking table gets cleared when provisioning new scope on table on SQLCE RRS feed

  • Question

  • I have N-Tier set up of the Sync Fx.

    Client side database  uses SQL CE 3.5 SP2 , Server uses SQL Server 2008.

    I have a table which has two type of Customer {Retail , Wholesale}.

    When client starts it choses what profile it need to load.

    If user choses Retail then table gets provisioned to sync as Retail customer. Customer & Customer_Tracking table all works fine.

    Now on same client next time  if user choses WholeSale then table gets provisioned to sync as WholeSale customer.

    - This time Customer_Tracking table gets cleared. Customer table still have all the records.

    - It Uploads all the Retail Customer data in sync operation to server while syncing wholesale scope. only first time.

    - When i check server profiler it tries to Insert the Retail Customer data on server.

    - I have UploadAndDownload as SyncDirectionOrder.

    Is this expected behaviour ?

    SQL CE table loses all tracking when new scope is provisioned to it?

    Is it not possible to hold both profiles (Retail , Wholsale) on the SQL CE side & only syncs the respective records?

    Saturday, December 11, 2010 10:45 PM


All replies

  • are you creating a filtered scope for the Wholesale and Retail? unfortunately, in your case, while the server scope has the filters, the filter is never applied on the SQL CE side when you provision.

    Monday, December 13, 2010 3:25 PM
  • Yes I'm creating filtered scope on the Server side.

    Client side I have following code to CreateScope :

     SqlCeConnection conn = (SqlCeConnection)localProvider.Connection;
                    SqlCeSyncScopeProvisioning sqlConfig = new SqlCeSyncScopeProvisioning(conn);
                    string scopeName = localProvider.ScopeName;

                    //if the scope does not exist in this store
                    if (!sqlConfig.ScopeExists(scopeName))
                        //create a reference to the server proxy
                        SqlSyncProviderProxy serverProxy = new SqlSyncProviderProxy(scopeName);

                        //retrieve the scope description from the server
                        DbSyncScopeDescription scopeDesc = serverProxy.GetScopeDescription(scopeName);


                        //use scope description from server to intitialize the client

    Server side GetScopeDescription method :

     public DbSyncScopeDescription GetScopeDescription(string scopeName)
                Log("GetSchema: {0}", this.peerProvider.Connection.ConnectionString);

                DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(scopeName, (SqlConnection)this.dbProvider.Connection);
                return scopeDesc;


    Do I need to apply the filters on the SQLCE side as well ?

    SqlCeSyncTableProvisioning doesn't seem to have support for FilterParameters.

    How to apply Filter on SQLCE Table ?

    Tuesday, December 14, 2010 7:53 AM
  • as you've already found out, you cant provision a filter on the SqlCeSyncProvider. you can do some filtering on the dataset itself on the SelectedChanges event as a workaround... a bit ugly though...

    Tuesday, December 14, 2010 11:17 AM
  • Can you please suggest the SelectedChanges event workaround.

    What needed to be done in SelectedChanges event in order to restrict the other profile related sync changes.

    If possible please post some code example or direct me to the appropriate resource.

    Because using SQL CE & supporting above scenario is must for our application.

    Tuesday, December 14, 2010 10:05 PM
  • check this post on how to go thru the dataset in the SelectedChanges: http://social.microsoft.com/Forums/en-US/syncdevdiscussions/thread/fbc354b7-6b5e-43f7-9560-e1d86477b161

    in your case, dont call Delete on the row, instead Remove the row.

    so if a Retail profile is being used, you would remove all Wholesale rows and you do the opposite for the Wholesale profile. as i have said, its an ugly workaround.

    can you not have multiple SQLCe Db on you client?

    • Marked as answer by veci_aus Thursday, December 16, 2010 10:45 PM
    Tuesday, December 14, 2010 11:12 PM
  • Multiple scopes are not supported on the Sql CE side.  I'm a bit confused by your first post, are you provisioning the client more than once?

    Wednesday, December 15, 2010 9:29 PM
  • Yes I'm provisioning the SQLCE side table more than once.

    I have implemented the work around that you suggested on the SelectedChanges.

    I'm removing the rows which are not related to the current sync scope from e.Context.Dataset

    That seems to sync the only rows concerned.  Thanks for suggesting work around.

    Will Sync FX support multiple scope on one table on SQLCE side in future ?

    Thursday, December 16, 2010 10:44 PM