locked
Sync Framework Conflicts Not being Detected? RRS feed

  • Question

  • Hi, I'm new to Sync Framework and working through the examples using Utility classes and How To code.  I ran the function "MakeConflictingChangesOnClientAndServer" and then ran a sync but it didn't raise an error.   Below is the code for the Synchronization.  

    The make conflicting changes deletes a record from the server and then updates it on the compact client.  When the synchronization runs, rather than throwing a conflict, it adds the record back to the server database and makes it match what is on the compact client.

    I tried in another example changing a field with the same key value on both the server and client (to different values).  Rather than throwing a conflict, the synchronization updated the value to whichever had the later timestamp in the tracking table, regardless of direction.

    Any suggestions on what I'm doing wrong?   Thanks in advance.  Cheryl

        
        static void SyncWithSql()
            {
                // create a connection to the SyncCompactDB database   
                SqlConnection clientConn = new SqlConnection("Data Source=localhost; Initial Catalog=SyncSamplesDb_SqlPeer1; Integrated Security=True");
    
    
                // create a connection to the SyncDB server database
                //SqlConnection serverConn = new SqlConnection("Data Source=localhost; Initial Catalog=SyncDB; Integrated Security=True");
    
                SqlCeConnection serverConn = new SqlCeConnection(@"Data Source='C:\SyncSQLServerAndSQLCompact\SyncSampleClient.sdf'");
    
                // create the sync orhcestrator
                SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
    
                // set local provider of orchestrator to a CE sync provider associated with the 
                // ProductsScope in the SyncCompactDB compact client database
                 //changes originate from local provider when uploading
                syncOrchestrator.LocalProvider = new SqlSyncProvider("CustomerScope", clientConn);
    
                // set the remote provider of orchestrator to a server sync provider associated with
                // the ProductsScope in the SyncDB server database
                syncOrchestrator.RemoteProvider = new SqlCeSyncProvider("CustomerScope", serverConn);
                
                // set the direction of sync session to Upload and Download
                //Upload means changes originate from the local provider and are applied to the remote provider. 
                //Download means changes originate from the remote provider and are applied to the local provider.
                syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
    
                // subscribe for errors that occur when applying changes to the client
                 ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
                ((SqlCeSyncProvider)syncOrchestrator.RemoteProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
    
                
                // execute the synchronization process
                SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
    
                // print statistics
                Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
                Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
                Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
                Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
                Console.WriteLine(String.Empty);
     
            }
    
    
    
            static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
            {
                // display conflict type
                Console.WriteLine(e.Conflict.Type);
    
                // display error message 
                Console.WriteLine(e.Error);
            }
    

    Wednesday, January 8, 2014 3:17 PM

All replies

  • Can you enable sync framework tracing in verbose mode and post the trace?

    Friday, January 10, 2014 12:02 PM