title: Why does this code cause an error?
body: <p>I have been looking for hours on how to connect to my local SQL database. I can't believe its been this difficult. Anyway, i think I am more on the right track with this code.</p>
  
  <pre><code>&lt;%
      Dim myConnection as System.Data.SqlClient.SqlConnection
      Dim myCommand as System.Data.SqlClient.SqlCommand
  
      myConnection = New System.Data.SqlClient.SqlConnection("Data Source=localhost;Initial Catalog=dbtest;Integrated Security=True")
      myConnection.Open()
  %&gt;
  </code></pre>
  
  <p>However, It still does not work. I don't know where to begin because I also get this message when the page loads:</p>
  
  <p><em>Runtime Error</em></p>
  
  <p><strong>Description:</strong> An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. </p>
  
  <p><strong>Details:</strong> To enable the details of this specific error message to be viewable on remote machines, please create a  tag within a "web.config" configuration file located in the root directory of the current web application. This  tag should then have its "mode" attribute set to "Off".</p>
  
  <p>I created a web.config file, and it didn't change anything. I'm so lost. Any help is appreciated! </p>
  
  <blockquote>
    <p>Stack Trace: [SqlException
    (0x80131904): Cannot open database
    "dbtest" requested by the login. The
    login failed. Login failed for user
    'IIS APPPOOL\DefaultAppPool'.]<br>
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
    exception, Boolean breakConnection)
    +6244425    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
    stateObj) +245<br>
    System.Data.SqlClient.TdsParser.Run(RunBehavior
    runBehavior, SqlCommand cmdHandler,
    SqlDataReader dataStream,
    BulkCopySimpleResultSet
    bulkCopyHandler, TdsParserStateObject
    stateObj) +2811<br>
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
    enlistOK) +53<br>
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
    serverInfo, String newPassword,
    Boolean ignoreSniOpenTimeout, Int64
    timerExpire, SqlConnection
    owningObject) +248<br>
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
    host, String newPassword, Boolean
    redirectedUserInstance, SqlConnection
    owningObject, SqlConnectionString
    connectionOptions, Int64 timerStart)
    +6260362    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
    owningObject, SqlConnectionString
    connectionOptions, String newPassword,
    Boolean redirectedUserInstance)
    +6260328    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
    identity, SqlConnectionString
    connectionOptions, Object
    providerInfo, String newPassword,
    SqlConnection owningObject, Boolean
    redirectedUserInstance) +354<br>
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
    options, Object poolGroupProviderInfo,
    DbConnectionPool pool, DbConnection
    owningConnection) +703<br>
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
    owningConnection, DbConnectionPool
    pool, DbConnectionOptions options) +54
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
    owningObject) +6261592<br>
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
    owningObject) +81<br>
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
    owningObject) +1657<br>
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
    owningConnection) +88<br>
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
    outerConnection, DbConnectionFactory
    connectionFactory) +6265031<br>
    System.Data.SqlClient.SqlConnection.Open()
    +258    ASP.index_aspx.__Render__control1(HtmlTextWriter
    __w, Control parameterContainer) +71    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter
    writer, ICollection children) +115<br>
    System.Web.UI.Page.Render(HtmlTextWriter
    writer) +38<br>
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean
    includeStagesAfterAsyncPoint) +4240</p>
  </blockquote>