C# How to Modify DataSet Connection Strings at Runtime?

2015/10/19 11:07
Detailed instructions by Paul Keister in his excellent article Adaptive Connection Strings for Windows Forms Applications

In brief

the connection string property is set read only in the Settings.Designer.cs class:
public string MyAppConnectionString {
   get {
            return ((string)(this["MyAppConnectionString"]));
         }
}
However, all application settings are accessible in read/write mode by using the indexer directly.  The following code demonstrates how to modify the connection string using this approach:
//change the application connection string
Properties.Settings.Default["MyAppConnectionString"] = strCnString;

//debug:verify that this really did work
Console.WriteLine(Properties.Settings.Default.MyAppConnectionString);