同步 2 个数据库时出现 DbNotProvisioned 异常
Posted
技术标签:
【中文标题】同步 2 个数据库时出现 DbNotProvisioned 异常【英文标题】:DbNotProvisioned Exception while synchronizing 2 database 【发布时间】:2011-04-19 13:31:53 【问题描述】:您好,以下是我的代码...我正在尝试同步 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】:您是否已配置数据库?如果没有,Sync Framework 附带的文档有教程可以做到这一点。或者你可以在这里查看:http://msdn.microsoft.com/en-us/library/ee617382(v=SQL.110).aspx
【讨论】:
以上是关于同步 2 个数据库时出现 DbNotProvisioned 异常的主要内容,如果未能解决你的问题,请参考以下文章