Please provide code to sync two SQL 2005 databases

Uzamčený Please provide code to sync two SQL 2005 databases

  • 9. prosince 2009 4:02
     
     
    Please provide code to sync two SQL 2005 databases

    Thanks,
    Diegolo
    • Přesunutý Hengzhe Li 21. dubna 2011 7:44 (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    •  

Všechny reakce

  • 9. prosince 2009 4:22
     
     
    it is in the MSDN,
    http://msdn.microsoft.com/en-us/library/dd918848%28SQL.105%29.aspx

    All you need to do is to change to use SqlSyncProvider in the code for both your server and nodes.

  • 9. prosince 2009 18:22
    Přispěvatel
     
     Odpovědět

    Yes, that's right.
    To be more precise, the difference to use a SQLCe Sync client and SQLServer Sync client is really minimal.
    I have summarized below the places where they differ:

    1. For provisioning.
    // Retrieve scope information from the server.          
    //
    DbSyncScopeDescription clientDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(scopeName, serverConn);

    if (peer.type == PeerType.SQL)
    {
        //For SQL client, do sync provisioning with the convenient Apply method directly.
        //
        SqlSyncScopeProvisioning clientProvisioning = new SqlSyncScopeProvisioning(clientDesc);
        clientProvisioning.Apply((SqlConnection) clientConn);
    }
    else if (peer.type == PeerType.SQLCe)
    {
        // For SQL Ce client, do sync provisioning with the convenient Apply method directly.
        //
        SqlCeSyncScopeProvisioning clientSqlCeProvisioning = new SqlCeSyncScopeProvisioning(clientDesc);
        clientSqlCeProvisioning.Apply((SqlCeConnection)clientConn);
    }

    2. For syncing with orchestrator, assume at this time, LocalProvider needs to be created.

    //when you create provider.
    //
    if (localConn is SqlCeConnection)
    {
        newSyncOrchestrator.LocalProvider = new SqlCeSyncProvider(scopeName, (SqlCeConnection)localConn);
    }
    else
    {
        newSyncOrchestrator.LocalProvider = new SqlSyncProvider(scopeName, (SqlConnection)localConn);
    }