Steven
Steven

Reputation: 41

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. 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.

Upvotes: 2

Views: 3045

Answers (4)

Crimsonland
Crimsonland

Reputation: 2194

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;"

Upvotes: 0

Dom
Dom

Reputation: 83

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.

Upvotes: 2

Steven
Steven

Reputation: 41

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.

Upvotes: 2

ErikEJ
ErikEJ

Reputation: 41819

Store the data in a folder that is not redirected.

Upvotes: 0

Related Questions