shruti
shruti

Reputation: 37

"Database is read-only" Exception

Server Error in '/' Application.

i tried all the things but im unable to write to database from another pc i am able to read but not able to write any solution ?

Failed to update database "C:\INETPUB\WWWROOT\APP_DATA\REPORT_DB.MDF" because the database is read-only. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Failed to update database "C:\INETPUB\WWWROOT\APP_DATA\REPORT_DB.MDF" because the database is read-only.

Source Error: 


Line 29:       cmd.Parameters.AddWithValue("@paswd", paswd);
Line 30:       cmd.Parameters.AddWithValue("@name", name);
Line 31:       cmd.ExecuteNonQuery();
Line 32:       con.Dispose();
Line 33:       

Upvotes: 0

Views: 2783

Answers (4)

Janusz Grabis
Janusz Grabis

Reputation: 174

I had the same kind of error ("Attempt to write a read-only database") after moving my app from XSP to IIS. I was missing Write permission for ASP.NET user on my database file. After adding that persmission everything started to work.

Upvotes: 1

Kamran Khan
Kamran Khan

Reputation: 9978

See that:

  • Your aspnet user has the modify rights on your App_Data folder
  • Check the file read/write attribute; right click and see if its not marked as readonly.

Upvotes: 0

Dustin Laine
Dustin Laine

Reputation: 38553

You need to navigate to that file, right click and select properties. Then uncheck the read only flag. It is simply the file permissions of the MDF file.

Upvotes: 1

sajoshi
sajoshi

Reputation: 2763

Go to App_Data folder and uncheck the readonly attribute from file REPORT_DB.MDF

Upvotes: 1

Related Questions