HOWTO: Use a ConnectionString from the web.config in your ASP.NET .CS code

In your .cs code you can pull the value of any ConnectionString using the following concept (where “blah” is the name of your connectionString as defined in your web.config file).

cn = new SqlConnection(ConfigurationManager.ConnectionStrings["blah"].ToString());

Leave a Reply