title: Connecting to SQLExpress from Classic ASP application
body: <p>I have a local SQLExpress database. I need to connect to this from a classic ASP web application.</p>
  
  <p>I think my connection string is correct because when I test using a C# console app I'm able to connect and read data:</p>
  
  <pre class="lang-c# prettyprint-override"><code>// C# Example app
  var connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=TestData;Integrated Security=True";
  var con = new SqlConnection(connectionString);
  
   con.Open();
   var cmd = new SqlCommand("SELECT * FROM tbl", con);
  
   cmd.ExecuteNonQuery();
   var reader = cmd.ExecuteReader();
   while(reader.Read())
   {
      Console.WriteLine(reader.GetValue(1)); // displays data
   }
  </code></pre>
  
  <p>However, when I use the same string in my ASP web application it fails:</p>
  
  <pre class="lang-js prettyprint-override"><code>// ASP Web App
  connection = Server.CreateObject("ADODB.Connection");
  connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=TestData;Integrated Security=True";
  Response.Write("connectionString:" + connectionString + "&lt;br/&gt;");
  connection.Open(Application(connectionString)); // error
  </code></pre>
  
  <p>The Open method fails with:</p>
  
  <blockquote>
    <p>0x80004005 - Microsoft OLE DB Provider for ODBC Drivers:
    [Microsoft][ODBC Driver Manager] Data source name not found and no
    default driver specified</p>
  </blockquote>
  
  <p>I also tried setting up a login for the SQL database and using a User Id and Password:</p>
  
  <pre><code>var connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=TestData;User Id=AspTest;Password=Test";
  </code></pre>
  
  <p>This fails in the same way.</p>
  
  <p>How can I get my web app to connect to my database?</p>