0

I'm trying to open a .SDF file using SQL Server CE 4.0 SP1. The .SDF file lives in C:\Program Files (x86). The permissions are set up so that normal users have read & execute permissions on the file. The client program is running as a regular user and tries to open the .SDF using this connection string:

"Data Source='{path-to-database-file}'; Password='{password}'; Max Database Size=4000;Mode=Read Only;Temp Path={users-temp-path};"

Opening a connection using that connection string results in

Internal error: Cannot open the shared memory region

The same code, when run as administrator, works perfectly.

If I add Modify & Write for all Users, it works perfectly as a regular user.

If I move the file to an app data folder, it works perfectly for that regular user.

Based on this evidence it looks like SQL Server CE cannot open a file for read only without the ability to write to the file.

Based on customer requirements nothing in C:\Program Files (x86) can be writable to regular users and all regular users need read-only access to the file.

What's up? What am I missing? Is this just not possible?

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ken Kauer
  • 21
  • 3
  • This is a windows file sharing issue. Windows isn't allowing two people to access file. – jdweng Feb 28 '20 at 21:19
  • Wonder if it is a platform move issue - see http://erikej.blogspot.com/2009/08/running-sql-compact-from-cd-rom-read.html ? – ErikEJ Mar 01 '20 at 16:46
  • Thanks for the response @ErikEJ. I've been to the link that you referenced, and thought that this was so similar to the case that we have, but I was never able to get the index rebuild (due to the platform change, or language change,, etc.) to happen without opening the file for read-write. – Ken Kauer Mar 02 '20 at 14:59
  • 1
    You cannot get the index rebuild to happen without opening for read-write, the trick is to avoid the need for it to happen at all. – ErikEJ Mar 02 '20 at 18:08
  • Thanks again @ErikEJ... Before we try to open the file read only from an application running under a normal user, we have a system service running under admin to open the file for read-write. This is supposed to insure that any normal user applications will not have to rebuild the indexes. We can see that the indexes are being rebuilt by the service, yet a normal user is unable to open the re-indexed file for read only. – Ken Kauer Mar 03 '20 at 20:44

0 Answers0