General help on sync providers. RRS feed

  • Question

  • Hi,

    I was just after some general help with the providers. I have two sqlexpress 2005 instances which need to synchronise in both directions.

    I started by using the DbServerSyncProvider, creating a SqlSyncAdapterBuilder as below:

    SqlCommand selectNewAnchorCommand = new SqlCommand();
    string newAnchorVariable = "@" + SyncSession.SyncNewReceivedAnchor;
    selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = min_active_rowversion() - 1";
    selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.Timestamp);
    selectNewAnchorCommand.Parameters[newAnchorVariable].Direction = ParameterDirection.Output;
    selectNewAnchorCommand.Connection = serverConn;
    DbServerSyncProvider.SelectNewAnchorCommand = selectNewAnchorCommand;
    SqlSyncAdapterBuilder customerBuilder = new SqlSyncAdapterBuilder(serverConn); 
    customerBuilder.TableName = "Customer"; 
    customerBuilder.TombstoneTableName = customerBuilder.TableName + "_Tombstone"; 
    customerBuilder.SyncDirection = SyncDirection.Bidirectional; 
    customerBuilder.ChangeTrackingType = ChangeTrackingType.CoupledChangeTracking; 
    customerBuilder.CreationTrackingColumn = "Sync_Created"; 
    customerBuilder.UpdateTrackingColumn = "Sync_Updated"; 
    customerBuilder.DeletionTrackingColumn = "DeletionDate"; 
    customerBuilder.CreationOriginatorIdColumn = "Sync_CreatedId"; 
    customerBuilder.UpdateOriginatorIdColumn = "Sync_UpdatedId"; 
    customerBuilder.DeletionOriginatorIdColumn = "CustomerId"; 
    SyncAdapter customerSyncAdapter = customerBuilder.ToSyncAdapter(true, true, true, true); 
    customerSyncAdapter.TableName = "Customer"; 

    I then tried two different ways of attaching the DbServerSyncProvider. A SyncAgent and SyncOrchestrator. Neither worked for me, returning an unhandled cast exception in KnowledgeProvider. I basically want to avoid writing all of the CRUD operations. Am I heading down the right path or is there something I am missing.


    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:38 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, November 10, 2009 10:09 AM