<connectionStrings> <add name="myconnection" connectionString="Data Source=ABC-PC\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True"/> </connectionStrings>
<connectionStrings> <add name="myconnection" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True; User Instance=True;AttachDbFilename=|DataDirectory|\mydatabase.mdf; Initial Catalog=mydatabase; "/> </connectionStrings>
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);