2

こんにちは以下は私のコードです...私は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);


        }
4

1 に答える 1

2

データベースをプロビジョニングしましたか?そうでない場合は、Sync Frameworkに付属のドキュメントに、それを行うためのチュートリアルがあります。または、ここで確認できます:http: //msdn.microsoft.com/en-us/library/ee617382 (v=SQL.110).aspx

于 2011-05-01T01:52:08.650 に答える