none
Sync Not Working RRS feed

  • Question

  • Hi,

    I am trying to set up an application that will syn with a server like a hub and spoke config.  Here are my steps.  I have set up a database with all the tables that will be on the client machine.  Then used the "SQL Azure Data Sync Tool for SQL Server" wizard To set up a matching database on Sql Azure.  I am using two way syncing.  After this I copy and deploy the local database that will be installed on the client machine.  I have not been able to get this working.  I do not get an error but the sync might work on one client but not the other or vise versa.  Am I going about this the wrong way?

     

    Thanks,

    Bryan

    Friday, April 16, 2010 4:44 PM

All replies

  • did you copy the SQL Agent jobs as well?
    Friday, April 16, 2010 5:08 PM
    Moderator
  • The client has the Sql Server 2008 Express edition that is installed during the installation.  I dont think express has the Agent?  So it is Sql Server 2008 Express (Spoke) to Sql Azure (Hub).  I am using the this method

     

            public static SyncOperationStatistics Synchronize()
            {

                SqlConnection source = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=ClientDb;Integrated Security=True");

                SyncOrchestrator syncOrchestrator = new SyncOrchestrator();

                syncOrchestrator.LocalProvider = new SqlSyncProvider("Sync_ClientDb", source);
                syncOrchestrator.RemoteProvider = new SqlAzureSyncProvider("Sync_ClientDb", @"Server=tcp:********.database.windows.net;Database=Spyder;User ID=UserID;Password=********;Trusted_Connection=False;");


                syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;

                ((SqlAzureSyncProvider)syncOrchestrator.RemoteProvider).MemoryDataCacheSize = 5120; //Batch Size set to 5 KB
                SyncOperationStatistics stats = syncOrchestrator.Synchronize();
                //Console.WriteLine("Stats:");
                //Console.WriteLine("Upload - Total: {0}, Failed {1}", stats.UploadChangesTotal, stats.UploadChangesFailed);
                //Console.WriteLine("Download - Total: {0}, Failed {1}", stats.DownloadChangesTotal, stats.DownloadChangesFailed); ;
                return stats;
            }

    Friday, April 16, 2010 5:20 PM
  • I'm just guessing here because I haven't worked on database sync myself. Your metadata is embedded in database? Then the copies will have same replica ids hence they are considered same replica. This will cause confusions at the best, I think.

    Friday, April 16, 2010 9:51 PM
  • i got it. You used the VS Wizard instead of the standalone utility.

    anyways, Friendly Dog may be right, instead of just copying the same database over and over to other clients, try provisioning them from an existing copy instead. (e.g., via SqlSyncDescriptionBuilder.GetDescriptionForScope and SqlSyncScopeProvisioning.PopulateFromScopeDescription)

    when you provision a peer copy of the database, it get's a replica id. when you sync, the same replica id is stored in the destination as well.

    when you make another copy of the database, you may have the same replica id, so when you synch with the destination, it will a record that says youve synced already.

    Saturday, April 17, 2010 3:16 AM
    Moderator
  • Thanks for the input.  I am new to all of this and not sure of the right way to go about it.  Does anyone know the correct way of deploying the database so the client can sync with the server?  Is there any whitepapers on this subject.

    Thanks,

    Bryan

    Saturday, April 17, 2010 2:49 PM
  • you can deploy an un-provisioned database, then have a piece of code to check if the scope exists in the database.

    for the provisioning part, you can actually have the provisioning engine generate the script for you so you can just run the script on each database replica.

    otherwise, you can code the provisioning part. the steps would be similart to this one: http://msdn.microsoft.com/en-us/library/dd918848(v=SQL.105).aspx, except that for the SQL Azure side, you have to use the SQLAzureSync provider.

    If you already have a working pair for example between Azure and SQL Express (i understand your issue is on the 2nd client), then you already have the scope defined in SQLExpress, so you can actually provision the 2nd client based on the scope definition from the 1st SQL Express client. You can then use SqlSyncDescriptionBuilder.GetDescriptionForScope to retrieve the scope definition from the 1st client and use SqlSyncScopeProvisioning.PopulateFromScopeDescription to configure the 2nd client.

    Saturday, April 17, 2010 4:25 PM
    Moderator
  • Would this be a script that is done against the client after they install the software?

     

    Thanks,

    Bryan

    Saturday, April 17, 2010 6:32 PM
  • the provisioning api can generate SQL scripts for creating the sync framework related objects in your database.

    you can use this script to initialize your database on the client.

    or you can also provision via the provisioning api

    Monday, April 19, 2010 10:59 PM
    Moderator
  • the provisioning api can generate SQL scripts for creating the sync framework related objects in your database.

    Is this api a tool.  Sorry for being dense but this is new for me.

     

    Bryan

    Wednesday, April 21, 2010 12:41 AM
  • API=Application Programming Interface.

    its the set of libraries available from the Sync Framework SDK you use/call to do your synchronization.

    Wednesday, April 21, 2010 3:46 AM
    Moderator
  • I blogged about how to get a scope description to upload from CE to Sql Azure. This is not the exact answer to your question but it does show the usage of the API's to get the scope description and send it to a different replica.

    http://blogs.msdn.com/mahjayar/archive/2009/11/18/sql-azure-data-sync-moving-schema-from-compact-database-to-sql-azure.aspx


    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Wednesday, April 21, 2010 6:00 PM
    Moderator
  • Thanks for the replies.  Does any no where there is any step by step guides on the subject or any good books that explain the process.

     

    Bryan

    Friday, April 23, 2010 12:45 PM
  • have you tried this? http://msdn.microsoft.com/en-us/library/dd918848(v=SQL.105).aspx

    just replace one of the providers with the SQL Azure provider.

    • Proposed as answer by Jandeep Thursday, April 29, 2010 8:24 PM
    Tuesday, April 27, 2010 12:17 AM
    Moderator