SQL Server CE +添加读写冲突避免?

发布于 2024-08-02 15:55:34 字数 696 浏览 2 评论 0原文

我们有一个 Office 插件,它使用 Sql CE 和通常的 DBConnection 到文件系统中的 *.sdf('C:/...etc...')。当我们启动具有 Sql CE 增强 Office 插件的应用程序的两个副本(测试用户可能会错误执行的操作)时,Sql CE 数据库会损坏,Office 插件无法再访问其数据。

我们似乎缺少一些避免看似显而易见的问题的基本方法。到目前为止,每个人都知道 Sql CE 不会锁定其行,从而允许多次写入同一 *.sdf 可能导致的损坏。

也许答案是“不要这样做”;并且 Sql CE 并不是为处理这种情况而设计的。但肯定大多数 Sql CE 应用程序都存在类似的风险,即错误地启动多个进程并尝试写入同一个 *.sdf?

我们喜欢 Sql CE 的小尺寸、自由性以及易于集成到我们的插件中。但我们查看了 Sql Server Express 和 2008 的比较: http://下载。 microsoft.com/download/A/4/7/A47B7B0E-976D-4F49-B15D-F02ADE638EBE/Compact_Express_Comparison.doc

We have an Office Addin that uses Sql CE with the usual DBConnection to a *.sdf in the filesystem ('C:/...etc...'). When we start two copies of the application having the Sql CE-augmented Office Addin (testing what a user might do by mistake) the Sql CE database becomes corrupted and the Office Addin can no longer access its data.

It seems like we are missing some basic way of avoiding a seemingly obvious problem. By now everyone knows that Sql CE does not lock its rows allowing the sort of corruption that multiple writes to the same *.sdf can cause.

Perhaps the answer is "don't do that;" and that Sql CE is not designed to handle this case. But surely most applications of Sql CE have a similar risk of mistakenly starting more than one process and attempting to write to the same *.sdf?

We like Sql CE's small size, free-ness, and easy integration to our addins. But we have looked at Sql Server Express and 2008 comparisons:
http://download.microsoft.com/download/A/4/7/A47B7B0E-976D-4F49-B15D-F02ADE638EBE/Compact_Express_Comparison.doc

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

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

发布评论

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

评论(1

咽泪装欢 2024-08-09 15:55:34

如果我正确理解您的用例并不真正需要两个正在运行的应用程序,那么您只需要在用户错误地执行此操作时捕获错误即可。

在这种情况下,检查您的插件是否已经运行就足够了(无论您的语言/框架支持什么......)。如果还有另一个实例,请不要实例化该插件。

If i understand that correctly your use-case does not really require two running applications, you just need to catch the error if the user does so by mistake.

In that case it should be sufficient to check if your addin is already running (whatever your language/framework supports for that...). If there is another instance, just don't instantiate the addin.

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