我正在使用Microsoft同步框架将数据从客户端上传到服务器。我已经成功配置了服务器和客户端。当我尝试执行ExecuteSync代码时,它表示已成功上载,但数据在服务器端SQL服务器数据库中不可用。对此高度赞赏的任何帮助
enter code here
using System;
using System.Data.SqlClient;
using Microsoft.Synchronization;
using Microsoft.Synchronization.Data;
using Microsoft.Synchronization.Data.SqlServer;
using System.Data;
namespace ExecuteSync
{
class Program
{
private static string scopename = "";
static void Main(string[] args)
{
SqlConnection clientConn = new SqlConnection(@"");
SqlConnection serverConn = new SqlConnection(@"");
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
syncOrchestrator.LocalProvider = new SqlSyncProvider(scopename, clientConn);
syncOrchestrator.RemoteProvider = new SqlSyncProvider(scopename, serverConn);
syncOrchestrator.Direction = SyncDirectionOrder.Upload;
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
Console.WriteLine("Uploads Failed: " + syncStats.UploadChangesFailed);
Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
Console.WriteLine(String.Empty);
Console.ReadLine();
}
static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
{
Console.WriteLine(e.Conflict.Type);
Console.WriteLine(e.Error);
}
}
}