none
Help in Synchronization RRS feed

  • Question

  • Hi

    We are using MS Sync Framework 2.1 in a WPF Application. The strange thing happening is that we are able to download the changes from the server but not able to upload the data changes to the server side. This synchronization code was sent by a previous developer of this project and we didn't changed a single bit of this code.

    Can you please help us in this matter. Do the sync framework problematic on the AMD machines?

    Also the behavior is inconsistent as somewhere it is uploading the database but not downloading and somewhere it is downloading and not uploading.

    Please help....

    Bhaskar Sharma

     

     

     


    Thursday, June 23, 2011 5:30 AM

All replies

  • which provider are you using?
    Thursday, June 23, 2011 6:27 AM
    Moderator
  • shall I give the class names?
    Thursday, June 23, 2011 6:38 AM
  • Sync Framework has SqlCeClientSyncProvider, SqlCeSyncProvider, DbServerSyncProvider, SqlSyncProvider? which one are you using? what databases are you synching?
    Thursday, June 23, 2011 6:44 AM
    Moderator
  • Using there

    DbSyncScopeDescription,SqlSyncScopeProvisioning,SqlSyncProvider,SyncOrchestrator,SyncOperationStatistics

     

    Synchronizing a SQL2008R2 Express database and SQL2008R2 Server database.

     


    Thursday, June 23, 2011 6:46 AM
  • how are the client databases initialized? what's the client database? are you copying the client databases from one client to another?

    it would help if you post some code snippets of provisioning and the actual sync.

    Thursday, June 23, 2011 6:52 AM
    Moderator
  • string myFranchiseCore = "FranchiseCore";

                SqlConnection myConnectionLocal = new SqlConnection(CCCUtility.CCCConnectionString());
                SqlConnection myConnectionServer = new SqlConnection(CCCUtility.CCCReplicationString());

                DbSyncScopeDescription clientScopeDetailGroup1 = SqlSyncDescriptionBuilder.GetDescriptionForScope(myFranchiseCore, null, "dbo", myConnectionServer);
                SqlSyncScopeProvisioning myClientScopeProvisionDetailGroup1 = new SqlSyncScopeProvisioning(myConnectionLocal, clientScopeDetailGroup1);
                myClientScopeProvisionDetailGroup1.SetUseBulkProceduresDefault(true);
                if (!myClientScopeProvisionDetailGroup1.ScopeExists(myFranchiseCore))
                {
                    myClientScopeProvisionDetailGroup1.Apply();
                }

                SqlSyncProvider mySQLProviderLocalDetailGroup1 = new SqlSyncProvider(myFranchiseCore, myConnectionLocal);
                SqlSyncProvider mySQLProviderServerDetailGroup1 = new SqlSyncProvider(myFranchiseCore, myConnectionServer);

                mySQLProviderLocalDetailGroup1.BatchingDirectory = Environment.ExpandEnvironmentVariables("%TEMP%");
                mySQLProviderServerDetailGroup1.MemoryDataCacheSize = 50000;
                mySQLProviderLocalDetailGroup1.MemoryDataCacheSize = 50000;
                mySQLProviderServerDetailGroup1.ApplicationTransactionSize = 10000;

                SyncOrchestrator mySyncOrchestratorDetailGroup1 = new SyncOrchestrator();
                mySyncOrchestratorDetailGroup1.LocalProvider = mySQLProviderLocalDetailGroup1;
                mySyncOrchestratorDetailGroup1.RemoteProvider = mySQLProviderServerDetailGroup1;
                mySyncOrchestratorDetailGroup1.Direction = SyncDirectionOrder.DownloadAndUpload;

                SyncOperationStatistics myStatsDetailGroup1 = mySyncOrchestratorDetailGroup1.Synchronize();
                state.Text = state.Text + "\r\nFranchise core replication started at :" + myStatsDetailGroup1.SyncStartTime.ToString() + " and finished at :" + myStatsDetailGroup1.SyncEndTime.ToString();
    Thursday, June 23, 2011 7:29 AM
  • are you copying the client databases from one client to another?

    Thursday, June 23, 2011 7:50 AM
    Moderator
  • Yes we are copying the changes from server to local database and vice versa
    Thursday, June 23, 2011 9:19 AM
  • thats not what i meant. if you have computer1 and computer2 as client computers, have you copied the actual database from computer1 to computer2 (backup from one machine, restored on another machine?)
    Thursday, June 23, 2011 10:33 AM
    Moderator
  • yes, we did the same.
    Thursday, June 23, 2011 12:56 PM
  • if you did a backup of a database and restored it on another machine, you have to run PerformPostRestoreFixup on the restored database before synching it. or you could start with a blank, unprovisioned database on your clients.

    you are encountering problems because Sync Framework thinks both databases are one and the same. so if DB1 syncs with Server and DB2 tries to sync with Server, Server thinks DB2 has already synched with it.

    Thursday, June 23, 2011 1:34 PM
    Moderator
  • What is PerformPostRestoreFixup and how this can be ran on the machine?
    Thursday, June 23, 2011 1:45 PM
  • you have to code it...look it up in the Sync Framework docs.

    http://207.46.16.248/en-us/library/ee617375(SQL.110).aspx

    Thursday, June 23, 2011 2:38 PM
    Moderator
  • THanks mate.

    This command worked fine and solved our problems.

    Bhaskar Sharma

    Monday, June 27, 2011 5:18 AM