Failed to update database...the database is read-only.

Topics: Help
Apr 18, 2007 at 7:10 PM
I downloaded the RC code, unzipped it into a new web application with host headers on port 80. Hit the site and end up with

Failed to update database C:\Inetpub\wwwstartersite\app_data\clubdb.mdf because the database is read-only.

It appears that the user control HitCounter.ascx cannot write to the database.

Do I need to update the schema on the clubdb with a script or something else? I checked the physcial file, it's not marked as read-only.
Apr 18, 2007 at 9:50 PM
It might be the directory that is read-only. Try making the wwwstartsite directory not read-only. It might also be your IIS config. Try runing it in VS.
Apr 27, 2007 at 12:50 AM
I don't think that is the case only because I have the same thing happening to me. I can mess around with the website all day long if I am using Visual Studio Web Developer Express to test the site using the local ASP.NET Development Web Server, but when I tried to use the Copy website tool and create a new web application with IIS, it gave me the "database read-only" (CLUBDB.MDF) when trying to load the web site from IE. I then read up on how to access the database via named pipes and one of the settings said the database was set to "Read-Only = True". Are you sure someone didn't inadvertently set this property?
Apr 27, 2007 at 3:05 PM
Here is the error you get if you try to open the CLUBDB.MDF and set the Read-Only property from "True" to "False":

TITLE: Microsoft SQL Server Management Studio Express

Alter failed for Database 'C:\INETPUB\WWWROOT\COFFEECLUB2\APPDATA\CLUBDB.MDF'. (Microsoft.SqlServer.Express.Smo)

For help, click:


An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)


Unable to open the physical file "C:\Inetpub\wwwroot\coffeeclub2\AppData\ClubDB.mdf". Operating system error 5: "5(Access is denied.)".
Unable to open the physical file "C:\Inetpub\wwwroot\coffeeclub2\AppData\ClubDB_log.ldf". Operating system error 5: "5(Access is denied.)".
Database 'C:\INETPUB\WWWROOT\COFFEECLUB2\APPDATA\CLUBDB.MDF' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
ALTER DATABASE statement failed.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
File activation failure. The physical file name "C:\Inetpub\wwwroot\coffeeclub2\AppData\ClubDB_log.ldf" may be incorrect. (Microsoft SQL Server, Error: 5120)

For help, click:


Apr 27, 2007 at 3:55 PM
This worked for me:
1) Make sure App_Data directory or any contained files does not have file system attribute Read-only set. (I had some files marked as Read-only)
2) Give user {machine name}\ASPNET Modify control over the CLUBDB.MDF and CLUBDB.LDF
3) Give user {machine name}\ASPNET Modify control over the App_Data directory.
4) Run IISRESET to restart IIS to refresh its permissions.

This is slightly different than the instructions I found here: