Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Locked Sync between 2 SQL 2008: Change Tracking

  • Sunday, February 15, 2009 6:52 PM
     
     
      http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=1200

    this example seems to work for SQL 2008 to an other version but not using Integrated change tracking

    I want to work with Change tracking between 2 SQL 2008 databases.
    I've tried to edit the code example, but i'm stuck

    look at folowing code

    DbServerSyncProvider serverSyncProvider = new DbServerSyncProvider();  
    SqlExpressClientSyncProvider clientSyncProvider = new SqlExpressClientSyncProvider();  
    SyncAgent syncAgent = new SyncAgent();  
    syncAgent.RemoteProvider = serverSyncProvider;  
    syncAgent.LocalProvider = clientSyncProvider

    It uses the SqlExpressClientSyncProvider, wich i don't want to uses, they write Change Tracking manually in it.(use guid, anchor table...)
    So i tried to assign a DBServerSyncProvider & DBSyncProvider to the clientSyncProvider variable

    but the problem is syncAgent.LocalProvider requires a clientSyncProvider wich is an abstract class..

    anyone knows how you fix the code to work with Change Tracking on both sides?

    • Moved by Hengzhe Li Friday, April 22, 2011 3:17 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    •  

All Replies

  • Thursday, February 19, 2009 1:31 PM
     
     Answered
    It's done when you create your sync table adapters:

    SyncTable syncTable = new SyncTable("MyTableName");
    syncTable.CreationOption = TableCreationOption...;
    syncTable.SyncDirection = SyncDirection...;
    syncAgent.Configuration.SyncTables.Add(syncTable);
    SqlConnection conn = (serverSyncProviderConnection);
    SqlSyncAdapterBuilder serverTableAdapterBuilder = new SqlSyncAdapterBuilder(conn);
    serverTableAdapterBuilder.TableName = "MyTableName";
    serverTableAdapterBuilder.ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking;
    serverTableAdapterBuilder.SyncDirection = entity.SyncDirection;
    SyncAdapter syncServerAdapter = serverTableAdapterBuilder.ToSyncAdapter();
    syncServerAdapter.TableName = "MyTableName";
    _serverSyncProvider.SyncAdapters.Add(syncServerAdapter);

    //CLIENT
    //do similar thing for the client table adapter


    You may want to read these articles:
    How to: Use SQL Server Change Tracking
    and 
    Getting Started: Client and Server Synchronization

  • Monday, April 06, 2009 10:05 PM
     
     

    Does anyone know how to Get and Set the Table Receive and Sent anchors using integrated change tracking. I am using the sample posted and am trying to change the code for integrated change tracking, but on the SetTableReceivedAnchor I am getting the following error: Object reference not set to an instance of an object.

    the paramater @anchor value anchor.Anchor has a value of nothing. I suspect I am not retrieving the anchors correctly. Any ideas on how to do this?

  • Tuesday, May 12, 2009 4:48 PM
     
     
    Did anyone manage to solve the problem? I'm allso stuck with implementation of GetTableReceivedAnchor and GetTableSentAnchor to work with SQL 2008 change tracking...