开发者

DbNotProvisioned Exception while synchronizing 2 database

Hi following is my code...I am trying to synchronize 2 database.. but getting exception like:

DbNotProvisioned Exception

The current operation could not be completed because the database is not provisioned for sync or you not have permissions to the sync configuration tables.

        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 D开发者_JS百科ownload
            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);


        }


have you provisioned your databases? if not, The documentation that comes with Sync Framework has tutorial for doing that. or you can check it out here: http://msdn.microsoft.com/en-us/library/ee617382(v=SQL.110).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜