简体   繁体   English

通过网络共享的SQL CE

[英]SQL CE over a network share

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. 我有一个使用SQL CE来存储本地信息的现有C#应用程序。 This database is only accessed by a single application and is stored in the user's appdata folder. 该数据库只能由单个应用程序访问,并存储在用户的appdata文件夹中。

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." 某些环境将appdata文件夹重定向到网络共享,这会导致SQL CE引发异常:“内部错误:无法打开共享内存区域。”

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. 我已经读到SQL CE 3.5 SP2应该允许再次连接到网络共享,而SP1不允许,但是我无法使其正常工作。 Has anybody had any success getting any version of SQL CE to work over a network share? 有没有人成功获得任何版本的SQL CE通过网络共享工作? 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. 我试过在连接字符串中使用mode = Exclusive,但没有运气。

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. 数据需要存储在用户配置文件中,因为每个用户都是特定数据,并且系统上的其他任何用户都不能访问该数据。

I updated the application to use SQL Express with local user instances which worked, but it created too many deployment issues for our customers. 我更新了该应用程序,以使其可以在本地用户实例中使用SQL Express,但是它为我们的客户带来了太多的部署问题。 I ended up having to write a layer to use Access MDBs while we look at different database options. 当我们研究不同的数据库选项时,我最终不得不编写一个层来使用Access MDB。

My suggestion for writing desktop applications is DO NOT use SQL express or SQL CE for local storage. 我对编写桌面应用程序的建议是,请勿将SQL Express或SQL CE用于本地存储。

I've used SQL CE 3.5 successfully on a networked drive with instances of an application running simultaneously on two networked computers. 我已经在联网驱动器上成功使用了SQL CE 3.5,并且在两台联网计算机上同时运行了一个应用程序实例。 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. 只需在连接字符串中包含数据库位置即可。

将数据存储在未重定向的文件夹中。

SQL Compact is a single-user, in-process database engine. SQL Compact是单用户进程内数据库引擎。

Have you tried to put sqlce DB on a shared folder and set its datasource where it is located? 您是否尝试过将sqlce DB放在共享文件夹上并设置其数据源在哪里?

Something like: 就像是:

"Data Source=\\MySharedfolder\\DB.sdf;Persist Security Info=False;"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM