title: What is the best method to handle connection string in windows form application?
body: <p>My C# application use <code>DataSet</code> and <code>TableAdapters</code>. They are generated form VS2008 GUI Tool.</p>
  
  <p>Example:</p>
  
  <blockquote>
    <p>Right click project - > Add New Item - > DataSet</p>
  </blockquote>
  
  <p>This method add a connection string automatically into <code>app.config</code>.</p>
  
  <p>But this is hard corded method for connection string. I want to change the connection string in a easy way. But when I used data set, then connection string get from application property.
  Are there any solution for this situation? </p>
  
  <p><img src="https://i.stack.imgur.com/zZ7AF.png" alt="enter image description here"></p>
  
  <p>This is my connection string store in <strong>Settings.Designer.cs</strong> file</p>
  
  <pre><code>    namespace WindowsFormsApplication2.Properties {
  
  
      [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
      [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
      internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
  
          private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
  
          public static Settings Default {
              get {
                  return defaultInstance;
              }
          }
  
          [global::System.Configuration.ApplicationScopedSettingAttribute()]
          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
          [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
          [global::System.Configuration.DefaultSettingValueAttribute("Data Source=SLCERT\\SQLEMK;Initial Catalog=TestDataBase;Integrated Security=True")]
          public string TestDataBaseConnectionString {
              get {
                  return ((string)(this["TestDataBaseConnectionString"])); // this is the connection string get from the dataset's
              }
          }
      }
  }
  </code></pre>
  
  <p>app.config contains</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="WindowsFormsApplication2.Properties.Settings.TestDataBaseConnectionString"
              connectionString="Data Source=SLCERT\SQLEMK;Initial Catalog=TestDataBase;Integrated Security=True"
              providerName="System.Data.SqlClient" /&gt;
      &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>