Failed to update database because the database is read only

This message appears every time I try to save the data to the DB.

Failed to update database because the database is read only 

Note: This error comes only when the application is installed to C drive.

Front End: VB.NET

Back End:SQL Server

Is there any way to overcome this issue? Or any way to restrict the user from installing the application on C drive?

9

2 Answers

I would check the file system privileges. I suppose you talk about an SQL server file database. You receive the message because the account trying to access your file database does not have the file system permissions to do so.

  1. In order to confirm my suggestion, you allow everyone to access the specific directory with full permissions.

  2. Then, you have to check what is the account trying to do the actual access. Probably it's a system account (user ASPNET or NETWORK SERVICE). You have to give the respective permissions to the specific account.

  3. Then, restart IIS.

If you want to do this for a distributed stand-alone application. Then these permissions would have to change on each machine where the program would be installed. In order to avoid putting users in such a fuss, the setup program should do it. I am not an expert on setup programs, but even the simplest ones would give you the option to do it, after asking the system adminstrator's approval. I suppose you could build a custom action during the setup program which would change the specific folder's permissions, perhaps by using xcacls.exe.

Hope I helped!

6

I have migrated the database from one environment to other and I was facing this issue. Following steps worked for me:

  • Check whether you can execute update statement on any table in the database (Make sure you have connected to db using same user that application is using).
  • If yes, then this error should not be there.
  • If no, toggle the option Database Read-Only from SQL server [Right click on database -> Properties -> Options -> Database Read-Only]. (For me this option was false still I was getting the error. So I toggled it twice and it worked.)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like