none
Data not synced RRS feed

  • Question

  • Hi All,

    I am trying to sync data from one database to other database on the same server. Both of these tables have different records initially then I started the sync.  The first upload & download sync direction works, I made some changes to both tables (adding and deleting of records) and sync again.  This time, I noticed that changes that I made to the second table are updated not not the first table.  Is there something that I missed?  Do I need to include the "Snapshot Initialization Process" in the code?

    TIA,

    S


    star921
    Wednesday, June 30, 2010 4:10 AM

All replies

  • what providers are you using? have you checked for conflicts by subscribing to the ApplyChangesFailed event?
    Wednesday, June 30, 2010 9:46 AM
    Moderator
  • Hi JuneT,

    I followed the MS sample code and I added one string parameter to it.  How do I check for conflicts with ApplyChangesFailed event?

     

    /// <summary>

     

    /// Utility function that will create a SyncOrchestrator and synchronize the two passed in providers

     

    /// </summary>

     

    /// <param name="localProvider">Local store provider</param>

     

    /// <param name="remoteProvider">Remote store provider</param>

     

    /// <returns></returns>

     

    public SyncOperationStatistics SynchronizeProviders(RelationalSyncProvider localProvider, RelationalSyncProvider remoteProvider, int syncDirection)

    {

     

    SyncOrchestrator orchestrator = new SyncOrchestrator();

    orchestrator.LocalProvider = localProvider;

    orchestrator.RemoteProvider = remoteProvider;

     

     

    switch (syncDirection)

    {

     

    case 0: orchestrator.Direction = SyncDirectionOrder.Upload;

     

    break;

     

    case 1: orchestrator.Direction = SyncDirectionOrder.Download;

     

    break;

     

    case 2: orchestrator.Direction = SyncDirectionOrder.DownloadAndUpload;

     

    break;

     

    case 3: orchestrator.Direction = SyncDirectionOrder.UploadAndDownload;

     

    break;

    }

     

    //status window (remove)

     

    //progressForm = new ProgressForm();

     

    //progressForm.Show();

     

    //Sync Status (?)

     

    //progressForm is a Form that shows sync status

     

    SyncOperationStatistics stats = orchestrator.Synchronize();

     

    progressForm.ShowStatistics(stats);

    progressForm.EnableClose();

     

    return stats;

    }

    TIA


    star921
    Wednesday, June 30, 2010 4:23 PM
  • you would do something like this to subscribe to the event:

       localProvider.ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(dbProvider_ApplyChangeFailed);
       remoteProvider.ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(dbProvider_ApplyChangeFailed);

    and then handle the ApplyChangeFailed event

    check out the docs at: http://msdn.microsoft.com/en-us/library/cc761628.aspx

     

    Thursday, July 1, 2010 6:21 AM
    Moderator