Please provide code to sync two SQL 2005 databases
-
2009. december 9. 4:02Please provide code to sync two SQL 2005 databases
Thanks,
Diegolo- Áthelyezte: Hengzhe Li 2011. április 21. 7:44 (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
Az összes válasz
-
2009. december 9. 4:22it 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.
-
2009. december 9. 18:22Válaszadó
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);
}- Válasznak javasolta: Jin H. _Microsoft Employee, Editor 2009. december 9. 18:22
- Válasznak való javaslatot visszavonta: Jin H. _Microsoft Employee, Editor 2009. december 9. 20:06
- Megjelölte válaszként: Diegolo 2009. december 9. 23:10