本地数据缓存同步不会保存客户端更改SDF文件 [英] Local Data Cache Sync does not save client changes to sdf file

查看:215
本文介绍了本地数据缓存同步不会保存客户端更改SDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的C#项目,并follwed的步骤从本教程创建LocalDataCache:

I created a new c# project and follwed the steps from this tutorial to create a LocalDataCache:

HTTP :?//www.codeproject.com/KB/database/AdoSyncServicesArticalPKg.aspx FID = 1526739&安培; DF = 90安培; MPP = 25安培,噪音= 3及排序=位置和放大器;查看=快速和放大器;选择= 2794305&安培; FR = 1#xx0xx

我旁边添加以下代码:

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);
        }
    }
}



我做出一些改变数据库服务器上,并执行同步和它出现更新客户端数据网格。当我重新加载应用程序,在客户端(SDF数据库)是一样的前同步发生和没有改变已被存储。

I make some changes to the database on the server and perform the sync and it appears update the client datagrid. When I re-load the application, the client (sdf database) is the same before the sync took place and no changes have been stored.

现在我不知道我失踪?一定是简单的东西!任何的建议是greatfully接受。

Now I am not sure what I am missing? Must be something simple! Any advice is greatfully accepted.

感谢您

推荐答案

这是现在解决了。

的问题是,database.sdf总是复制到数据输出目录和将覆盖我工作的数据库(手动更改测试合并!) 。

The problem is that the database.sdf is always copied to the data output directory and would overwrite the database I was working on (manually making changes to test the merge!).

这可以通过点击在Visual Studio和性能SDF文件来改变改变复制到输出目录到不要复制的价值。然后,管理数据目录之外的连接字符串。默认值是副本如果有更新引起的问题!

This can be changed by clicking on the sdf file in visual studio and in properties change the value for "Copy to Output Directory" to "Do Not Copy". Then manage the connection string outside of the data directory. The default is Copy If newer which caused the problems!

这篇关于本地数据缓存同步不会保存客户端更改SDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆