Bonjour à tous,
Voilà j'ai un soucis avec le syncframework 2.1, j'explique :
Je suis sur SQL Server et je veux synchroniser 2 bases. J'ai utilisé cette procédure : http://msdn.microsoft.com/fr-fr/library/ff928699.aspx.
Mais quand je lance la synchro, j'ai une erreur :
Impossible de terminer l'opération en cours car la base de données n'est pas configurée pour la synchronisation ou vous ne disposez pas des autorisations nécessaires dans les tables de synchronisation.
L'erreur apparait lors de l'éxecution de la ligne :
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
Est ce que ça concerne les droits de l'utilisateur ? Si oui, comment lui donner les droits ?
Voici mon 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
|
SqlConnection serverConn = new SqlConnection("Data Source=****;Initial Catalog=SyncDBServeur;Integrated Security=True");
// define a new scope named ProductsScope
DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("maprod");
// get the description of the Products table from SyncDB dtabase
DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Products", serverConn);
// add the table description to the sync scope definition
scopeDesc.Tables.Add(tableDesc);
SqlConnection clientConn = new SqlConnection("Data Source=****;Initial Catalog=SyncDBClient;Integrated Security=True");
// create a server scope provisioning object based on the ProductScope
SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(clientConn, scopeDesc);
// skipping the creation of table since table already exists on server
serverProvision.SetCreateTableDefault(DbSyncCreationOption.CreateOrUseExisting);
// start the provisioning process
serverProvision.Apply();
// create the sync orhcestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
// set local provider of orchestrator to a CE sync provider associated with the
// ProductsScope in the SyncCompactDB compact client database
syncOrchestrator.LocalProvider = new SqlSyncProvider("maprod", serverConn);
// set the remote provider of orchestrator to a server sync provider associated with
// the ProductsScope in the SyncDB server database
syncOrchestrator.RemoteProvider = new SqlSyncProvider("maprod", clientConn);
// set the direction of sync session to Upload and Download
syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
} |
Merci de votre aide
Partager