title: SQL Connection failed after deployment: "Login failed for user '' "
body: <p>I'm having a problem with my ASP.NET Application after I have deployed it. Everything was working well in debug mode, however after deployment any page that attempts to connect to the DB gives this error:</p>
  
  <p>Login failed for user ''.</p>
  
  <p>My SQLConnection String is: </p>
  
  <pre><code>sdb.ConnectionString = "Data Source=&lt; SQLServerAddress &gt;;Initial Catalog=sdb;";
  </code></pre>
  
  <p>Originally I had</p>
  
  <pre><code>Integrated Security=true;
  </code></pre>
  
  <p>Appended to my connection string, however this resulted in a similar error message: </p>
  
  <blockquote>
    <p>"Login failed for user '&lt; domain >\&lt; computer name >$'."</p>
  </blockquote>
  
  <p>I am new to IIS but have followed guides to set it up. My site is using the DefaultAppPool with its identity set to NetworkService (Although I have tried ApplicationPoolIdentity and it seems to change nothing.)</p>
  
  <p>I've added the NT AUTHORITY\NETWORK SERVICE account in SQL server for my database as db_owner permissions as well. </p>
  
  <p>Under the Authentication settings I have Anonymous Authentication user identity set to "Application pool identity".</p>
  
  <p>I have given permissions to the C:\inetpub\wwwroot folder to NETWORK SERVICE but that didn't seem to help anything either. </p>
  
  <p>I'm really not sure what else to try. I can see that the problem must be with permissions or identities since everything worked well in Visual Studio debugging, but I'm not sure where the problem is post-deployment. This is my first IIS deployment and is for a project for my undergrad computer science program at university. I've been searching google for a good part of the day and tried many applicable suggestions but unfortunately nothing seems to be working, and I'm a bit unsure of what to search for now for a solution.</p>
  
  <p>I'm not sure if it matters or not but I connect to my database all from codebehind, the code to connect and a bit of how I'm using it is as follows:</p>
  
  <pre><code>SqlDataSource sdb = new SqlDataSource();
  sdb.ConnectionString = "Data Source=&lt; SQLServerAddress &gt;;Initial Catalog=sdb;";
  sdb.SelectCommand = "SELECT someAttribute, someOtherAtt FROM SomeTable";
  dropDownList.DataSource = sdb;
  dropDownList.DataTextField = "someAttribute";
  dropDownList.DataValueField = "someOtherAtt";
  </code></pre>