Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have just finished my setup of asp.net application. I put my database into App_Data folder. My problem is it is working fine when i try to run from my application before setup.. But when i try to run from IIS (Internet information Server) after installation, it gives error :
C#
CREATE DATABASE permission denied in database 'master'.
Cannot attach the file 'C:\inetpub\wwwroot\BigProject\App_Data\project.mdf' as database 'project'.

My connection string is like below..
C#
<connectionStrings>
    <add name="database_con" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\project.mdf;Initial Catalog=project;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>


I searched almost everything on google but didn't find anything. Hope you will Help me.. Any help would be appreciated. How to solve this prolbem??
Posted
Comments
Bh@gyesh 17-Apr-14 7:29am    
Hi Harpreet,
When you deploy your application on IIS, It will take identity of IIS user, not logged in user. From connection string it seems that your are using window authentication for SQL server but it is not possible from IIS.
So pass userid and password in connection string. It may resolve your problem.
Harpreet_125 17-Apr-14 13:14pm    
But i did not set any username or password for database..
j snooze 17-Apr-14 14:18pm    
You can add one. If you used Microsoft SQL Server Management Studio, open your SQLExpress database under the object explorer. Expand the Security option. Right click on Logins and enter a new login name. Choose SQL Server authentication, and give it a good password. If you are worried about the plain text in your config file, you can encrypt it using the aspNet_regiis see http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx for usage.

1 solution

Option 1:
Your keyword are: application pool identities
You need to set App Pool user an account have permission to create DB on SQL
http://www.iis.net/learn/manage/configuring-security/application-pool-identities

Option 2:
Give a try to remove "Initial Catalog=project;" from your connection string.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900