Why is System.Data.SqlClient.SqlConnection class throwing an exception that "The parameter is incorrect"?
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.
Here are the steps I've taken that lead up to this:
Created a new SQL Server database in my project
App_Datafolder, calledTestSQLdb.mdf.Created a connection string in
web.config:<add name="SQLTestConnection1" connectionString="Data Source=(LocalDB);initial catalog=TestSQLdb;Integrated Security=true" />Access the connection string through
string cn_str = ConfigurationManager.ConnectionStrings["SQLTestConnection1"].ConnectionString;(See this SO thread for more info on this).
Created a new connection:
SqlConnection conn = new SqlConnection(cn_str);Attempt to open the connection:
try { conn.Open();At this point, an exception is thrown.
I tried to set this up so it would be simple and easy to learn on. What am I missing?