locked
VS2008 (Release): Bi-directional data update. RRS feed

  • Question

  • Where can I find a working example of how to do a Bi-directional update.  I've been working through the data walkthroughs and cannot get the program to upload changed data. It reloads the data from the SQL server without uploading any changes in the customer table.  Note: Since I'm totally new to this API, probably something simple like missing a setting or property.

     

    Thanks for any help

     

    Ed Warren.

     

    ---------snippet----

     

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim syncAgent As CustomersCacheSyncAgent = New CustomersCacheSyncAgent

     

    'this should allow bidirectional updates.

    syncAgent.Customers.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional

     

    Using syncClient As New ServiceReference1.CustomersCacheSyncContractClient

    syncAgent.RemoteProvider = New Microsoft.Synchronization.Data.ServerSyncProviderProxy(syncClient)

    Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize

    NorthwindDataSet.Customers.Merge(New LocalNorthwindCustomersTableAdapters.CustomersTableAdapter().GetData())

    Dim syncSummary As String = "Total changes downloaded: " & _

    syncStats.TotalChangesDownloaded.ToString() & vbCrLf & _

    "Total changes uploaded: " & _

    syncStats.TotalChangesUploaded.ToString() & vbCrLf & _

    "Last successful synchronization: " & _

    syncStats.SyncCompleteTime.ToString

    MessageBox.Show(syncSummary)

    End Using

    End Sub

    • Moved by Max Wang_1983 Friday, April 22, 2011 8:57 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Sunday, January 13, 2008 10:51 AM

Answers

  • Hi Ed,

     

    In order to make the bidir scenario work. you need to have :

    1. setup the syncdirection as bidir, as you have already done

    2. ensure you Server side sync adapters has the update/insert/delete command constructed. you can use the sqldbsyncadapterbulder class to do so

    3. correct tracking logic and anchor values to ensure data and conflicts are handled correctly.

     

    you can check out the sample under http://www.syncguru.com/projects/SyncServicesDemoConflictHandling.aspx for the bidir cases.

     

    thanks

    yunwen

     

    Tuesday, January 15, 2008 11:32 PM
    Moderator

All replies

  • Reviewing my post, I realize I have not provided the steps I have taken to get into this situation.

     

    here are the walkthroughs I have worked through.

     

    Walkthrough: Creating an N-Tier Data Application-- works fine
    Walkthrough: Adding Validation to an N-Tier Data Application -- interesting improvement over vs2005, works.
    Walkthrough: Adding a Local Database Cache to an N-Tier Application -- really cool works


    How to: Configure a Local and Remote Database for Bidirectional Synchronization --ugh! must be some steps missing here like setting up the service to return the data.

     

    -----button click event-----fails to update the server----

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim syncAgent As CustomersCacheSyncAgent = New CustomersCacheSyncAgent

    'this should allow bidirectional updates.

    syncAgent.Customers.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional

    Using syncClient As New ServiceReference1.CustomersCacheSyncContractClient

    syncAgent.RemoteProvider = New Microsoft.Synchronization.Data.ServerSyncProviderProxy(syncClient)

    Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize

    NorthwindDataSet.Customers.Merge(New LocalNorthwindCustomersTableAdapters.CustomersTableAdapter().GetData())

    Dim syncSummary As String = "Total changes downloaded: " & _

    syncStats.TotalChangesDownloaded.ToString() & vbCrLf & _

    "Total changes uploaded: " & _

    syncStats.TotalChangesUploaded.ToString() & vbCrLf & _

    "Last successful synchronization: " & _

    syncStats.SyncCompleteTime.ToString

    MessageBox.Show(syncSummary)

    End Using

    End Sub

    -------------end snip--------------------

     

    Thanks for any help

     

    Ed Warren.

     

     

    Tuesday, January 15, 2008 2:45 AM
  • Hi Ed,

     

    In order to make the bidir scenario work. you need to have :

    1. setup the syncdirection as bidir, as you have already done

    2. ensure you Server side sync adapters has the update/insert/delete command constructed. you can use the sqldbsyncadapterbulder class to do so

    3. correct tracking logic and anchor values to ensure data and conflicts are handled correctly.

     

    you can check out the sample under http://www.syncguru.com/projects/SyncServicesDemoConflictHandling.aspx for the bidir cases.

     

    thanks

    yunwen

     

    Tuesday, January 15, 2008 11:32 PM
    Moderator
  • Thanks ever so much for the kind reply.  I will most certainly check out your example.  As I thought there was a lot missing from the examples.  I was beginning to wonder the more I saw the note that the sync service was one way only.

     

    I'm trying to work through this new technology, but it seems to change faster than I can learn :>

     

    Thanks

     

    Ed Warren.

    Wednesday, January 16, 2008 2:42 AM
  • Thanks Ed.

     

    I agree there a serveral issues in the samples and we appreciated all you the folks here catching them up and let us know about them.

     

    the API has been undergoing some reviews and changes based all the feedbacks we got from all the sources we got. we understand that will introduce some inconveniences for some existing application developers, but in the long run, to make things right as beginnin will benefit all of us. :-)

     

    Best Regards.

    Yunwen

     

    Sunday, January 20, 2008 7:40 PM
    Moderator
  • For the absolute NEWBIE (ME), I finally found a good simple working example that I could walkthrough and understand.

     

    Here is the URL: Presented by Liam Cavanagh:  http://msdn2.microsoft.com/en-us/sync/cc137124.aspx

     

    This is a link to a video that walks through the steps one by one.  At the end you have a very basic, simple application that will do bidrectional updates

     

    Now if I could just unravel mystery of how to deploy the code to a production server!!

     

    Ah well, it seems that with each bit of knowlege comes more questions.

     

    Ed Warren

     

    Monday, January 21, 2008 2:30 PM