Mohammad Dayyan
Mohammad Dayyan

Reputation: 22448

Database '...\DATABASE.MDF' cannot be upgraded because it is read-only or has read-only files

I wanna install an ASP.NET application on WIN XP SP3,
Thus I've installed IIS 5.1 , .Net Framework 3.5 SP1 and MSSQL 2008 R2 on my WinXP SP3.
Then, I copied my application folder to C:\Inetpub\wwwroot\
Next, I've created an application from my folder in IIS Manager and I set the permissions as the following image :

enter image description here

As you can see, I can't write and even read from the database and whenever I wanna write into the database I receive the above exception.
What's the wrong with it ?

P.S:
I'm using Win XP on VMware Workstation 7.1
The application is running in Win Vista x86 and Win7 x64 without any problems.
The application was written with .Net Framework 3.5 SP1

Upvotes: 1

Views: 5605

Answers (5)

Abdulkarim Kanaan
Abdulkarim Kanaan

Reputation: 1763

You add Users group into the sercurity tab with Full Control

enter image description here

Upvotes: 0

Simon_Weaver
Simon_Weaver

Reputation: 146120

This was weird. It turned out part of my application was referencing one aspnetdb file in Sql Server and the other was trying to reference one locally created in the application.

My connection string was for this :

<add name="ApplicationServices" 
     connectionString="Data Source=localhost; Initial Catalog=aspnetdb; Integrated Security=True" providerName="System.Data.SqlClient" />

But the error was this

There was a failure using the default 'ProfileProvider'. Please make sure it is configured correctly. Database 'C:\WEBSITES\XXXX.SILVERLIGHT\ADMIN\APP_DATA\ASPNETDB.MDF' cannot be upgraded because it is read-only, has read-only files or the user does not have permissions to modify some of the files. Make the database or files writeable, and rerun recovery.

It took me a while to notice that this was under my application root, and not the Sql Server version that the main part of my application uses.

In my case I just renamed the locally created aspnetdb files and when I reran the pplication it just recreated them at their default sizes (10240kb and 504kb).

I'm not quite sure how this is happening, but i my case this was a sufficient fix.

I think maybe I wasn't using the profile provider explicitly so it was using default settings. The rest of the application was using the correct connection string.

Upvotes: 0

Adilson de Almeida Jr
Adilson de Almeida Jr

Reputation: 2755

You must edit permissions, allowing "Network Service" to edit the MDF file.

Upvotes: 2

Mohammad Dayyan
Mohammad Dayyan

Reputation: 22448

I've found the solution. I disabled the Windows Firewall and shared the folder with `Allow Users to change my files" , and now I can write and read from the database easily :-)

Upvotes: 0

mmorel
mmorel

Reputation: 444

Did you check your database file's property (readonly attribute), and ACL security permissions (permissions that are defined on the file level - not in the IIS management console) ?

Upvotes: 0

Related Questions