Pooh
Pooh

Reputation: 105

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?

Upvotes: 4

Views: 30899

Answers (2)

Arjun Mandavkar
Arjun Mandavkar

Reputation: 31

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

Upvotes: 1

Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

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!

Upvotes: 4

Related Questions