从SQL CE数据库使用Microsoft Sync上载到SQL Server

时间:2016-02-08 17:05:55

标签: c# sql-server microsoft-sync-framework

我已经搜索过这个但是很难找到有关成功将更改从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数据库。走向另一个方向似乎是一个挑战。

0 个答案:

没有答案