同步2个数据库时DbNotProvisioned异常
|
您好以下是我的代码...我正在尝试同步2个数据库..
但得到像这样的异常:
DbNotProvisioned异常
当前操作无法完成,因为未为同步配置数据库,或者您没有同步配置表的权限。
private void btnSync_Click(object sender, EventArgs e)
{
//create a connection to the second compact database
SqlCeConnection clientConn = new SqlCeConnection(@\"Data Source=\'E:\\SyncClient.sdf\'\");
//create connection to the server database
SqlConnection serverConn = new SqlConnection(@\"Data Source=.\\sqlexpress; Initial Catalog=SyncDB; Integrated Security=True\");
// create a sync orchestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
// set the local provider to a CE sync provider associated with the
// ProductsScope in the Sync Compact DB 2 database
syncOrchestrator.LocalProvider = new SqlCeSyncProvider(\"ProductsScope\", clientConn);
// set the remote provider to a server sync provider associated with the
// ProductsScope in the Sync DB server database
syncOrchestrator.RemoteProvider = new SqlSyncProvider(\"ProductsScope\", serverConn);
// set the diretion to Upload and Download
syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
// execute the synchronization process
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
//print sync statistics
string message=\"Start Time: \"+syncStats.SyncStartTime+\"\\nTotal Changes Uploaded: \"+syncStats.UploadChangesTotal;
MessageBox.Show(message);
}
没有找到相关结果
已邀请:
1 个回复
陈獭