Synchronisation BDD Client/Serveur
Bonjour, je souhaite réaliser une synchronisation de 5 tables entre un base de données Client et un serveur (distant) en utilisant SQL Server 2008 R2 .
voici un extrait de mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
//partie serveur distant
serverConn= new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MaBDDServeur;Integrated Security=True");
string scope = "sync_tables";
DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(scope);
DbSyncTableDescription Table1 = SqlSyncDescriptionBuilder.GetDescriptionForTable("MaTable1", serverConn);
//pareil avec table2 ... jusqu'a 5.
scopeDesc.Tables.Add(Table1);
//pareil avec table2 ... jusqu'a 5.
SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(scopeDesc);
//les tables existes, pas besoin de les créer.
serverConfig.SetCreateTableDefault(DbSyncCreationOption.skip);
serverConfig.Apply(serverConn);
//partie client
SqlConnection clientConn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=MaBDDClient;Integrated Security=True");
scope = "sync_tables";
DbSyncScopeDescription clientSqlDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(scope,serverConn);
SqlSyncScopeProvisioning clientSqlConfig = new SqlSyncScopeProvisioning(clientSqlDesc);
clientSqlConfig.Apply(clientConn);
SyncOrchestrator sync = new SyncOrchestrator();
sync.Direction = SyncDirectionOrder.UploadAndDownload;
sync.LocalProvider = new SqlSyncProvider(scope, clientConn);
sync.RemoteProvider = new SqlSyncProvider(scope, serverConn);
sync.Synchronize();
SqlSyncScopeDeprovisioning deprovisionScope = new SqlSyncScopeDeprovisioning(serverConn);
deprovisionScope.DeprovisionScope("sync_tables"); |
Mon 1er problème est que je ne comprend pas comment fonctionne la ligne suivante:
Citation:
sync.Direction = SyncDirectionOrder.UploadAndDownload;
Pour l'instant ce qu'il se passe c'est que toute les tables sélectionnées sont copiées dans la base de données client mais comment faire pour mettre a jour ces champs ensuite ? si je refait une synchronisation cela suffit t'il pour les mettres a jour ?
merci de vos conseils d'avance.
KevDeta
p.s: c'est la première fois que je touche à la synchronisation de BDD.