Lokalna synchronizacja pamięci danych nie zapisuje zmian klienta w pliku sdf
Stworzyłem nowy projekt c # i wykonałem kroki z tego samouczka, aby utworzyć LocalDataCache:
Następnie dodałem następujący kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestLocalSync
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the table. You can move, or remove it, as needed.
this.databaseTableAdapter.Fill(this.testDataSet.myTable);
}
private void Sync_Click(object sender, EventArgs e)
{
dataGridView1.EndEdit();
// 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.testTable.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
MessageBox.Show("Changes downloaded: " +
syncStats.TotalChangesDownloaded.ToString() +
Environment.NewLine +
"Changes uploaded: " + syncStats.TotalChangesUploaded.ToString());
// TODO: Reload your project data source from the local database (for example, call the TableAdapter.Fill method).
databaseTableAdapter.Fill(testDataSet.myTable);
testDataSet.Merge(databaseTableAdapter.GetData());
databaseTableAdapter.Update(testDataSet);
}
private void Refresh_Click(object sender, EventArgs e)
{
databaseTableAdapter.Fill(testDataSet.myTable);
}
}
}
Wprowadzam pewne zmiany do bazy danych na serwerze i wykonuję synchronizację i wydaje się, że aktualizuje datagrid klienta. Po ponownym załadowaniu aplikacji klient (baza danych sdf) jest taki sam przed przeprowadzeniem synchronizacji i nie zostały zapisane żadne zmiany.
Teraz nie jestem pewien, czego mi brakuje? To musi być coś prostego! Wszelkie porady są bardzo akceptowane.
Dziękuję Ci