none
Sync Framework not downloading updates RRS feed

  • Question

  • I followed the tutorial on this page and changed some of the code because I'm using MSSQL 2008 on both client and server.
    http://msdn.microsoft.com/en-us/library/ff928699(v=SQL.110).aspx

    I'm able to sync the remote db if rows are Deleted or Inserted into the server database but not for rows that were Updated.

    What did I do wrong?

     

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim serverConn As SqlConnection = New SqlConnection("Data Source=TH-PC; Initial Catalog=mice; Integrated Security=True")
        Dim scopeDesc As DbSyncScopeDescription = New DbSyncScopeDescription("PredicatesScope")
        Dim tableDesc As DbSyncTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable("Predicates", serverConn)
        scopeDesc.Tables.Add(tableDesc)
        Dim serverProvision As SqlSyncScopeProvisioning = New SqlSyncScopeProvisioning(serverConn, scopeDesc)
        serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip)
        serverProvision.Apply()
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim clientConn As SqlConnection = New SqlConnection("Data Source=TH-PC; Initial Catalog=mice_local; Integrated Security=True")
        Dim serverConn As SqlConnection = New SqlConnection("Data Source=TH-PC; Initial Catalog=mice; Integrated Security=True")
    
        Dim scopeDesc As DbSyncScopeDescription = SqlSyncDescriptionBuilder.GetDescriptionForScope("PredicatesScope", serverConn)
        Dim clientProvision As SqlSyncScopeProvisioning = New SqlSyncScopeProvisioning(clientConn, scopeDesc)
        clientProvision.Apply()
      End Sub
    
      Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim clientConn As SqlConnection = New SqlConnection("Data Source=TH-PC; Initial Catalog=mice_local; Integrated Security=True")
        Dim serverConn As SqlConnection = New SqlConnection("Data Source=TH-PC; Initial Catalog=mice; Integrated Security=True")
    
        Dim syncOrchestrator As SyncOrchestrator = New SyncOrchestrator()
    
        syncOrchestrator.LocalProvider = New SqlSyncProvider("PredicatesScope", clientConn)
        syncOrchestrator.RemoteProvider = New SqlSyncProvider("PredicatesScope", serverConn)
        syncOrchestrator.Direction = SyncDirectionOrder.Download
    
        Dim syncStats As SyncOperationStatistics = syncOrchestrator.Synchronize()
     
      End Sub

    Thursday, September 30, 2010 8:33 AM

Answers

All replies

  • can you check on the remote provider's ChangesSelected event if the updates are being picked up?  and if theyre being picked up, check in the local provider's ApplyChangesFailed event if there are any errors/conflicts being raised?
    Thursday, September 30, 2010 4:02 PM
    Moderator
  • The link you gave (http://msdn.microsoft.com/en-us/library/ff928699(v=SQL.110).aspx)  seems are for server provision. Is this the sample you have issue?

     

    Thanks,


    Ann Tang
    Thursday, September 30, 2010 9:20 PM
  • I added the following lines to the Button3.Click event

    AddHandler DirectCast(syncOrchestrator.LocalProvider, SqlSyncProvider).ApplyChangeFailed, AddressOf Program_ApplyChangeFailed

    AddHandler DirectCast(syncOrchestrator.LocalProvider, SqlSyncProvider).ChangesSelected, AddressOf Program_ChangesSelected

     

    Private Shared Sub Program_ChangesSelected(ByVal sender As Object, ByVal e As DbChangesSelectedEventArgs)           MsgBox(e.Context.DataSet.Tables(0).Rows.Count)

    End Sub

     

      Private Shared Sub Program_ApplyChangeFailed(ByVal sender As Object, ByVal e As DbApplyChangeFailedEventArgs)

            Console.WriteLine(e.[Error])

        End Sub

     

    I then made changes, save the remote database and then I click Button3. The message was "0" and there were no error messages.

    Friday, October 1, 2010 6:00 AM
  • I went thru all 4 walkthroughs in the Mandatory Walkthrough section.

    http://msdn.microsoft.com/en-us/library/ff928494(v=SQL.110).aspx

    Friday, October 1, 2010 6:01 AM
  • you should listen to the ChangesSelected on the remoteprovider instead of the localprovider.

    does the ApplyChangeFailed event fire at all?

    can you post the table structure and what were you updating and ill see if i can reproduce.

    Friday, October 1, 2010 10:38 AM
    Moderator
  • I deleted the databases and redo the walkthrough and this time everything works. Changes made to the remote database are downloaded to the local database. Not sure what I did wrong in my first try.

    Anyway, thanks for your help.

     

     

    Saturday, October 2, 2010 6:38 AM