title: ASP.NET connection string to local SQL Server database, using web.config
body: <p>Why is <code>System.Data.SqlClient.SqlConnection</code> class throwing an exception that "The parameter is incorrect"?</p>
  
  <p>I'm attempting to learn how to set up database connections using a local SQL database and an ASP.NET MVC project, using .NET framework 4.5.</p>
  
  <p>Here are the steps I've taken that lead up to this:  </p>
  
  <ol>
  <li><p>Created a new SQL Server database in my project <code>App_Data</code> folder, called <code>TestSQLdb.mdf</code>.  </p></li>
  <li><p>Created a connection string in <code>web.config</code>:  </p>
  
  <pre><code>&lt;add name="SQLTestConnection1" 
       connectionString="Data Source=(LocalDB);initial catalog=TestSQLdb;Integrated Security=true" /&gt;  
  </code></pre></li>
  <li><p>Access the connection string through  </p>
  
  <pre><code>string cn_str = ConfigurationManager.ConnectionStrings["SQLTestConnection1"].ConnectionString;
  </code></pre>
  
  <p>(See <a href="https://stackoverflow.com/a/6134384/2658159">this SO</a> thread for more info on this).  </p></li>
  <li><p>Created a new connection:  </p>
  
  <pre><code>SqlConnection conn = new SqlConnection(cn_str);
  </code></pre></li>
  <li><p>Attempt to open the connection:  </p>
  
  <pre><code>try
  {
       conn.Open();
  </code></pre>
  
  <p>At this point, an exception is thrown.</p></li>
  </ol>
  
  <p>I tried to set this up so it would be simple and easy to learn on. What am I missing?</p>