title: programmatically change mysql connection string using c#
body: <p>I want to change the app.setting connection string at the run time. I have some code to change it but i can't do this. there is no error appear during the run time. But there is no change during execution.</p>
  
  <p>This is my partial code :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
      &lt;/configSections&gt;
      &lt;connectionStrings&gt;
          &lt;add name="Punch_Uploader.Properties.Settings.testConnectionString"
              connectionString="server=localhost;User Id=root;password=test123;database=test"
              providerName="MySql.Data.MySqlClient" /&gt;
          &lt;add name="Punch_Uploader.Properties.Settings.testConnectionString1"
              connectionString="server=172.23.2.52;User Id=root;password=test123;database=test"
              providerName="MySql.Data.MySqlClient" /&gt;
      &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And:            </p>
  
  <pre><code>Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  config.ConnectionStrings.ConnectionStrings.Add(
      new ConnectionStringSettings("Punch_Uploader.Properties.Settings.testConnectionString2", 
          String.Format(
              "server={0};Port={1}; database={2};User Id={3};password={4};providerName={5}", 
              "172.23.2.32", "3306", "test", "root", "test123", "MySql.Data.MySqlClient")
          )
  );
  config.Save(ConfigurationSaveMode.Modified, true);
  ConfigurationManager.RefreshSection("connectionStrings"); 
  
  MessageBox.Show(ConfigurationManager
      .ConnectionStrings["Punch_Uploader.Properties.Settings.testConnectionString2"]
      .ConnectionString);
  </code></pre>
  
  <p>The above code is not working for me....</p>
  
  <p>Please help me to fix this.</p>