title: Cannot open database requested in login 'Database1'. Login fails. Login failed for user 'sa'
body: <p>I got the above error when i deploy my web application into windows server 2003. How do i resolve it?</p>
  
  <p>Login.aspx.vb</p>
  
  <pre><code>Dim connection As String = System.Configuration.ConfigurationManager.ConnectionStrings("database").ConnectionString()
  
  Dim mycon As New SqlConnection(connection)
  </code></pre>
  
  <p>Web.config</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="database" connectionString="Data Source='172.20.145.67';Initial Catalog='Database1';User ID='sa';Password='321'"/&gt;
   &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>[SqlException (0x80131904): Cannot open database requested in login 'Database1'. Login fails.
  Login failed for user 'sa'.]
     System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131
     System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
     System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
     System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
     System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
     System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
     System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
     System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
     System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
     System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
     System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
     System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
     System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
     System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
     System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
     System.Data.SqlClient.SqlConnection.Open() +111
     WebApplication1.Login.ImageButton2_Click(Object sender, ImageClickEventArgs e) in C:\Users\Pei Wen\Desktop\SHS\fyp final.16\WebApplication1\Login.aspx.vb:20
     System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
     System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
     System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
     System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
     System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
  </code></pre>