rkulp
asked on
Permission Denied Error Accessing SQLServerCE File
In VB 2013 I am accessing a SQLServerCE 3.5 file with the following connection string in app.config:
This has worked great on several computers but now I'm getting an access denied error indicating I don't have permission to access the db. This also happens when running as administrator. The db is in
As a test, I set the permissions to allow full control to all users. This does not make any difference.
The installation package creates the required folders if they don't already exist. So, what have I done wrong and what is best practice in this situation?
<connectionStrings>
<add name="IncentiveEval.My.MySettings.RIMSIIConnectionString"
connectionString="Data Source=|DataDirectory|\RIMSII.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
This has worked great on several computers but now I'm getting an access denied error indicating I don't have permission to access the db. This also happens when running as administrator. The db is in
Public gDatabasePath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\IncentiveEval\"
In the ApplicationEvents Startup I have the following: If My.Computer.FileSystem.FileExists(gDatabasePath + "RIMSII.sdf") Then
AppDomain.CurrentDomain.SetData("DataDirectory", gDatabasePath)
File.SetAttributes(gDatabasePath + "RIMSII.sdf", FileAttributes.Normal)
End If
As a test, I set the permissions to allow full control to all users. This does not make any difference.
The installation package creates the required folders if they don't already exist. So, what have I done wrong and what is best practice in this situation?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
funwithdotnet,
Well, I cannot gain access to C:\ProgramData at all, whether I am logged in as user or administrator. That is why the folder was not created. This has happened on two computers, one a Win 8.1 and the other a Win 10, both running 64-bit OS. I was able to install the program successfully on a Win 10 computer with the 32-bit OS.
I ensured that the file was not in the place that the error message had said it could not find it, either on the development computer or the end-user's computer. The code never searches anywhere but C:\ProgramData\IncentiveEv al. I can't explain the error message.
Playing with permissions on the installation package does not change anything. Even logged on as administrator, I cannot display the folders in C:\ProgramData.
The only difference between the Windows 10 computers that deny permission and those that don't seems to be whether the last Windows 10 update has been installed. The computer I installed the program on this morning had not been rebooted to install the update. The one that did not allow permission yesterday had been rebooted to install the update. Interesting, but probably not the real cause. It is worth looking into.
Thanks for your interest. I'll keep you posted.
Well, I cannot gain access to C:\ProgramData at all, whether I am logged in as user or administrator. That is why the folder was not created. This has happened on two computers, one a Win 8.1 and the other a Win 10, both running 64-bit OS. I was able to install the program successfully on a Win 10 computer with the 32-bit OS.
I ensured that the file was not in the place that the error message had said it could not find it, either on the development computer or the end-user's computer. The code never searches anywhere but C:\ProgramData\IncentiveEv
Playing with permissions on the installation package does not change anything. Even logged on as administrator, I cannot display the folders in C:\ProgramData.
The only difference between the Windows 10 computers that deny permission and those that don't seems to be whether the last Windows 10 update has been installed. The computer I installed the program on this morning had not been rebooted to install the update. The one that did not allow permission yesterday had been rebooted to install the update. Interesting, but probably not the real cause. It is worth looking into.
Thanks for your interest. I'll keep you posted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked on the other computer. I will consider the problem solved.
ASKER
I figured it out and listed the steps that solved the problem. funwithdotnet's suggestions pointed me in the right direction. I am very appreciative.
ASKER
Clearly, I have some work to do. Thanks for your help. I'll get back soon (I hope).