Click here to Skip to main content
14,421,575 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have just finished my setup of 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 :
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..
    <add name="database_con" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\project.mdf;Initial Catalog=project;Integrated Security=True" providerName="System.Data.SqlClient"/>

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??
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 for usage.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Option 1:
Your keyword are: application pool identities
You need to set App Pool user an account have permission to create DB on SQL

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

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100