Failed to update database because the database is read only

14,579

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!

Share:
14,579
Pooh
Author by

Pooh

Updated on June 08, 2022

Comments

  • Pooh
    Pooh almost 2 years

    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?

    • PM 77-1
      PM 77-1 over 10 years
      What is your OS? Where on C: drive is it installed?
    • Pooh
      Pooh over 10 years
      Windows 7 installed to C:
    • sam yi
      sam yi over 10 years
      I'm not sure what is going on here but this looks like a sql error and not an operating system error. In other words, it's probably not related to your "C" drive (I doubt your C drive is in "read-only"). Try running this... exec sp_dboption 'databasename','read only'
    • Pooh
      Pooh over 10 years
      i can do this.. but the user may nt know to do all these.. any idea why this happens like this?
    • sam yi
      sam yi over 10 years
      exec sp_dboption 'databasename','read only' allows you to check if the database is in "read-only" mode. If it is, you can set it to READ_WRITE... ALTER DATABASE database-name SET READ_WRITE WITH NO_WAIT
    • rudi bruchez
      rudi bruchez over 10 years
    • PM 77-1
      PM 77-1 over 10 years
      Does your user have admin privileges?
    • Pooh
      Pooh over 10 years
      yaa.. admin privileges r der..
    • Pooh
      Pooh over 10 years
      @rudibruchez: ua link gave me a hint. n it worked. but every user after the installation should change the permission of the DB. its hectic for them.. they may not have that much knowledge. this application is standalone. any soution for this? any changes to b made to DB during deployment?
  • Pooh
    Pooh over 10 years
    yeah.. but every user after the installation should change the permission of the DB. its hectic for them.. they may not have that much knowledge. this application is standalone.
  • Pantelis Natsiavas
    Pantelis Natsiavas over 10 years
    Or perhaps your installation program could change the permissions, after asking the PC administrator's approval of course...
  • Pantelis Natsiavas
    Pantelis Natsiavas over 10 years
    Glad to help anyway. Please, upvote the answer so that other users who bump on your question would know the solution...
  • Pooh
    Pooh over 10 years
    installation program is vb setup project.. does it hve any solution to over come this problem?