In VS, look at the Solution Explorer.
Under your poject, open the "Properties" branch.
Double click "Settings.settings"
Add a user string called "ConnectionString"
Close and save the settings.
In your code:
string conStr = Properties.Settings.Default.ConnectionString;
using (SqlConnection con = new SqlConnection(strCon))
{
using (SqlCommand com = new SqlCommand("SELECT * from MyTable", con))
{
SqlDataReader r = com.ExecuteQuery();
while (r.Read())
{
....
}
}
}
When you change it, and want to save:
Properties.Settings.Default.ConnectionString = conStr;
Properties.Settings.Default..Save();