通过网络共享的 SQL CE
我之前见过这个问题,但找不到关于什么是可能/不可能以及什么解决方法可能可用的明确解释。
我有一个现有的 C# 应用程序,它使用 SQL CE 来存储本地信息。该数据库只能由单个应用程序访问,并存储在用户的 appdata 文件夹中。
某些环境将 appdata 文件夹重定向到网络共享,这会导致 SQL CE 引发异常:“内部错误:无法打开共享内存区域。”
我读到 SQL CE 3.5 SP2 应该允许再次连接到网络共享,而 SP1 则不允许,但是我无法让它工作。有没有人成功地让任何版本的 SQL CE 通过网络共享工作?如果是这样,您使用什么版本/代码来让它工作?
我尝试在连接字符串中使用 mode=Exclusive 但没有成功。
或者,有人找到了不同的解决方法吗?数据需要存储在用户的配置文件中,因为它是每个用户特定的,并且系统上的任何其他用户都不应访问该数据。
I have seen this question asked previously but can not find a clear explanation of what is/isn't possible and what workarounds migth be available.
I have an existing C# application that uses SQL CE to store local information. This database is only accessed by a single application and is stored in the user's appdata folder.
Some environments have the appdata folder redirected to a network share which causes SQL CE to throw an exception: "Internal error: Cannot open the shared memory region."
I have read that SQL CE 3.5 SP2 is supposed to allow connections to network shares again, and that SP1 does not, however I have not been able to get it to work. Has anybody had any success getting any version of SQL CE to work over a network share? And if so, what version/code did you use to get it to work?
I have tried using mode=Exclusive in the connection string with no luck.
Or alternatively, has anybody found a different workaround? The data needs to be stored in the user's profile as it is specific per user and should not be accessible by any other user on the system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我更新了应用程序以将 SQL Express 与本地用户实例一起使用,这有效,但它给我们的客户带来了太多部署问题。当我们查看不同的数据库选项时,我最终不得不编写一个层来使用 Access MDB。
我对编写桌面应用程序的建议是不要使用 SQL Express 或 SQL CE 进行本地存储。
I updated the application to use SQL Express with local user instances which worked, but it created too many deployment issues for our customers. I ended up having to write a layer to use Access MDBs while we look at different database options.
My suggestion for writing desktop applications is DO NOT use SQL express or SQL CE for local storage.
我已经在联网驱动器上成功使用了 SQL CE 3.5,并且应用程序实例在两台联网计算机上同时运行。我能够从两个位置更新数据库中的记录。
我不确定如果两个用户同时访问同一条记录会发生什么,但是在我的情况下这不太可能。只需在连接字符串中包含数据库位置即可。
I've used SQL CE 3.5 successfully on a networked drive with instances of an application running simultaneously on two networked computers. I was able to update records in the database from both locations.
I'm not sure what would happen if two users accessed the same record at the same time, however this is unlikely in my situation. Just include the database location in the connection string.
将数据存储在未重定向的文件夹中。
Store the data in a folder that is not redirected.
SQL Compact 是一个单用户、进程内数据库引擎。
您是否尝试过将 sqlce DB 放在共享文件夹上并将其数据源设置在它所在的位置?
像这样的东西:
SQL Compact is a single-user, in-process database engine.
Have you tried to put sqlce DB on a shared folder and set its datasource where it is located?
Something like: