Sql Server CE 3.5 合并复制同步挂起

发布于 2024-07-07 23:58:43 字数 1571 浏览 5 评论 0原文

我正在使用 SQL Server 2005 CE 框架 3.5,并尝试在我的手持设备和 SQL Server 之间使用合并复制。 当我运行代码进行同步时,它似乎永远不会停止,而当我在代码中放置断点时,它永远不会通过对 Synchronize() 的调用。

如果我查看 sql server 中的复制监视器,它会显示订阅不再同步并且不显示任何错误。 因此我假设这意味着同步已完成。

http://server/virtualdirectory/sqlcesa35.dll?diag 不报告任何问题。

这是我第一次尝试任何手持设备开发,所以我可能做了一些愚蠢的事情。 但是,SQL Server 似乎报告同步成功。

任何帮助将不胜感激,因为我在这方面花了很长时间!

这是我的代码。

const string DatabasePath = @"SD Card\mydb.sdf";
var repl = new SqlCeReplication
               {
                   ConnectionManager = true,
                   InternetUrl = @"http://server/virtualdirectory/sqlcesa35.dll",
                   Publisher = @"servername",
                   PublisherDatabase = @"databasename",
                   PublisherSecurityMode = SecurityType.DBAuthentication,
                   PublisherLogin = @"username",
                   PublisherPassword = @"password",
                   Publication = @"publicationname",
                   Subscriber = @"PPC",
                   SubscriberConnectionString = "Data Source=" + DatabasePath
               };
try
{
    Cursor.Current = Cursors.WaitCursor;
    if (!File.Exists(DatabasePath))
    {
        repl.AddSubscription(AddOption.CreateDatabase);
    }
    repl.Synchronize();
    MessageBox.Show("Successfully synchronised");
}
catch (SqlCeException e)
{
    DisplaySqlCeErrors(e.Errors, e);
}
finally
{
    repl.Dispose();
    Cursor.Current = Cursors.Default;
}

I am using SQL Server 2005 CE framework 3.5 and attempting to use merge replication between my hand held and my SQL Server. When I run the code to synchronise it just seems to sit forever, and when I put a breakpoint in my code it never gets past the call to Synchronize().

If I look at the replication monitor in sql server, it gets to the point where it says the subscription is no longer synchronising and doesn't show any errors. Therefore I am assuming this to mean the synchronisation is complete.

http://server/virtualdirectory/sqlcesa35.dll?diag does not report any issues.

This is my first attempt at any handheld development, so I may have done something daft. However, SQL Server seems to be reporting a successful synchronisation.

Any help would be greatly appreciated as I have spent ages on this !

Here is my code.

const string DatabasePath = @"SD Card\mydb.sdf";
var repl = new SqlCeReplication
               {
                   ConnectionManager = true,
                   InternetUrl = @"http://server/virtualdirectory/sqlcesa35.dll",
                   Publisher = @"servername",
                   PublisherDatabase = @"databasename",
                   PublisherSecurityMode = SecurityType.DBAuthentication,
                   PublisherLogin = @"username",
                   PublisherPassword = @"password",
                   Publication = @"publicationname",
                   Subscriber = @"PPC",
                   SubscriberConnectionString = "Data Source=" + DatabasePath
               };
try
{
    Cursor.Current = Cursors.WaitCursor;
    if (!File.Exists(DatabasePath))
    {
        repl.AddSubscription(AddOption.CreateDatabase);
    }
    repl.Synchronize();
    MessageBox.Show("Successfully synchronised");
}
catch (SqlCeException e)
{
    DisplaySqlCeErrors(e.Errors, e);
}
finally
{
    repl.Dispose();
    Cursor.Current = Cursors.Default;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抠脚大汉 2024-07-14 23:58:43

您可以做的另一件事是加快同步操作,指定 PDA 主程序内存中的数据库文件路径(而不是像示例中那样位于 SD 卡上)。 您应该会看到速度提高了 4 倍(这意味着同步时间可能只需要现在的 25%)。

如果您的 PDA 上的主程序内存不足,您可以在 Synchronize 调用后使用 System.IO.File.Move() 将文件移动到 SD 卡。 我知道这看起来有点奇怪,但是同步到程序存储器并复制到 SD 卡比直接同步到 SD 卡要快得多。

Another thing you can do to speed up the Synchronize operation is to specify a db file path that is in your PDA's main program memory (instead of on the SD Card as in your example). You should see a speed improvement of up to 4X (meaning the Sync may take only 25% as long as it's taking now).

If you're running out of main program memory on your PDA, you can use System.IO.File.Move() to move the file to the SD Card after the Synchronize call. This seems a bit strange, I know, but it's much faster to sync to program memory and copy to the SD card then it is to sync directly to the SD card.

≈。彩虹 2024-07-14 23:58:43

后来我发现将数据复制到物理磁盘需要很长时间。 虽然sql server复制已经完成,但它仍在将数据复制到sd卡。

我通过减少正在复制的表的数量来识别这一点,并且得到了更立即的响应(这是另一个错误,但与此问题无关)。

不管怎么说,还是要谢谢你 :)

I have since discovered that it was just taking a long time to copy the data to the physical disk. Although the sql server replication had completed, it was still copying the data to the sd card.

I identified this by reducing the amount of tables I am replicating and I got a more immediate response (well another error but unrelated to this issue).

Thanks anyway :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文