SQL CE over a network share

邮差的信 提交于 2019-12-13 02:26:24

问题


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.


回答1:


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.




回答2:


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.




回答3:


Store the data in a folder that is not redirected.




回答4:


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:

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


来源:https://stackoverflow.com/questions/5307593/sql-ce-over-a-network-share

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!