0
我已經在頁面加載事件中添加了這段代碼,並且本地數據庫中的數據正在與服務器數據庫同步,但我沒有找回服務器數據庫中的值。C#中的數據同步#
我還在論壇中提到的LocalDataCache1.sync中添加了代碼,並將database.sdf更改爲「不復制」。
來自服務器的數據正在填寫Tableadapter,但它不更新本地數據庫。
void HomeLoad(object sender, EventArgs e)
{
this.Validate();
clientBindingSource.EndEdit();
tableAdapterManager1.UpdateAll(this.DataSet);
// Call SyncAgent.Synchronize() to initiate the synchronization process.
// Synchronization only updates the local database, not your project’s data source.
LocalDataCache1SyncAgent syncAgent = new LocalDataCache1SyncAgent();
syncAgent.tbl_Miscellaneous.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
//TODO: Reload your project data source from the local database (for example, call the TableAdapter.Fill method).
miscellaneousTableAdapter1.Update(DataSet.Miscellaneous);
miscellaneousTableAdapter1.Fill(DataSet.Miscellaneous);
DataSet.Miscellaneous.Merge(this.miscellaneousTableAdapter1.GetData());
}
只是爲了說明,本地數據庫中的更改反映在服務器中,但服務器中的更改未同步回客戶端? – JuneT 2012-03-30 06:53:08
是的,你是對的JuneT,我正在接受與你所提到的相同的改變。 – Manju 2012-03-30 09:41:35
嘗試訂閱ApplyChangeFailed事件並查看是否存在應用服務器更改或訂閱服務器端ChangesSelected事件的錯誤,並確認是否已選擇更改。 – JuneT 2012-03-30 10:31:23