Q:

IIS SQL Server configuration

I have a C# ASP.net project which was developed using Visual studio for web 2013 and SQL Server express 2012.
I used a database connection line as follows:
SqlConnection objConnection = new SqlConnection("Data Source=.\\MYDB;Initial Catalog=MYDB;Integrated Security=true");
        objConnection.Open();

This worked fine when in developer mode in Visual Studio - but now I have deployed to IIS which runs under user IIS_IUSRS(Andy-PC\IIS_IUSRS). 
When I visit my pages they then throw the following error:
Server Error in '/' Application.

Cannot open database "MYDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\MYDB'.

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: Cannot open database "MYDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\MYDB'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[SqlException (0x80131904): Cannot open database "MYDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\MYDB'.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6749670
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815
   System.Data.SqlClien

Its pretty self explanatory - my connection string with integrated security=true is not successfully working as the current logged in user is not IIS_IUSRS.
Can somebody please help to show what I should alter the connection string to in order to create the connection when connecting as this new IIS user?

A:

You need to change the user that your application pool is running as.
Go to Advance Setting for the Application Pool and change the Identity to a user that can access your sql server.

