add connection string to app.Config file under tag such as
right click on solution explorer second and add reference System.Configuration
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["connStr1"].ConnectionString;
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr);
conn.Open();