A week ago I faced with a problem. I published my asp.net website on IIS6 and the connection with Sql Server didn’t work properly.
After a lot of googling and asking on forums I found a solution.
I’ll tell you now what was the problem:
Firstly I had a website which worked properly in Visual studio! , it had a connection with Ms Sql Server database, connection string and other properties was set correctly. After copying this website on local IIS (Windows XP, IIS6 ) when user was performing some action and application tried to connect to database there was an error: “Database is read-only or asp.net account has not write permission”.
It is easy to make file not to be read-only, you can just right click on file(or folder) than properties and uncheck read-only checkbox.
I tried this but it didn’t work.
Then I tried to grant access permissions to asp.net account. It is also easy to do this: just right click on web application folder in IIS manager and properties/ Directory security/ edit /browse/ advanced /search and than select asp.net account and OK.
I did all this but still this error.
I had no idea what the hell was going there :D
I asked about this problem on asp.net forum: http://forums.asp.net/p/1417250/3149474.aspx#3149474
There was a good answer which partly helped me:
If we deploy website on the IIS, this website is running under IIS account (in your case, it is ‘GABEDAVA\ASPNET’), which does not have permission to log in your Sql Server by default.
To use Windows Authentication correctly, we need to add this account to new login and set SQL Server to either Integrated authentication or Mixed-Mode authentication.
For more information, see http://www.asp.net/learn/whitepapers/aspnet-and-iis6/ (Section: Supporting integrated authentication with SQL Server).
We also can use SQL Server Authentication to login server. To do so, we need UserID and Password to connect database. The connection string should look like
“Server=YourServerAddress;Database=YourDataBase;Uid=YourUsername;Pwd=YourPassword;”
For more information, see http://www.connectionstrings.com/?carrier=sqlserver2005 and http://devilswork.wordpress.com/category/sql/
This is good explanation but it isn’t the exact answer.
Solution:
Then I found out that in windows tools/ folder option /view there is option “use simple file sharing” you should uncheck this checkbox and after this action when right click and properties on folder(or file) you have a new security tab where you can add user and set permissions and this isn’t the same, as action in IIS manager. You should grant full control of asp.net account on the folder and everything will be all right.
Yeh my web application works now on the server, IIS6 account (asp.net account) has permissions to access Sql server database (whew).
Filed under: .NET, ASP.NET Tagged: | .NET, ASP.NET, Database is read-only or asp.net account has not write permission, IIS, MS SQL Server











No need with all those solutions. You only need to remember the logon account the database was in before it was detached. When you reattach ensure you are in that logon account.