我已经搜索过这个但是很难找到有关成功将更改从SQL CE数据库上传到SQL Server的信息。
我的同步功能设置如下:
public int Synchronize() {
List<SyncOperationStatistics> syncStats = new List<SyncOperationStatistics>();
// set the direction of sync session to 'Download' because ony the server can be modified.
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
syncOrchestrator.Direction = SyncDirectionOrder.Upload;
foreach (var scopeName in ScopeNames) {
syncOrchestrator.LocalProvider = new SqlCeSyncProvider(scopeName, DB_SqlCeConnection);
syncOrchestrator.RemoteProvider = new SqlSyncProvider(scopeName, DB_SqlConnection);
// subscribe for errors that occur when applying changes to the client
((SqlCeSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
((SqlSyncProvider)syncOrchestrator.RemoteProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Remote_ApplyChangeField);
SyncOperationStatistics syncStat = null;
// execute the synchronization process
syncStat = syncOrchestrator.Synchronize();
// Add synchronization statistics to list
syncStats.Add(syncStat);
}
return syncStats.Count;
}
将syncOrchestrator.Direction
设置为Upload
后,我会收到错误
Cannot enumerate changes at the RelationalSyncProvider for table 'table1'.
我能够非常轻松地将更改从服务器同步到CE数据库。走向另一个方向似乎是一个挑战。