title: How to add connection string in Config File in WPF Application
body: <p>I am a beginner and learning WPF Application. I have a simple project and in that I want to read DB Configuration string from App.Config File. But I am not able to do so. Below is my attempt:</p>
  
  <p><strong>APP.Config File:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /&gt;
      &lt;/startup&gt;
    &lt;connectionStrings&gt;
      &lt;add name="DBCS" connectionString="Data Source=.\;Initial Catalog=Connect;Integrated Security=SSPI" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>CS Code:</strong></p>
  
  <pre><code>    public static void GetDataFromDB()
              {
                  //var CS = @"Data Source=.\;Initial Catalog=Connect;Integrated Security=SSPI";
                 // ABOVE CODE WORKS FINE
                  string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
                  using (SqlConnection con = new SqlConnection(CS))
                  {
                      con.Open();
                      SqlDataAdapter da = new SqlDataAdapter("Select * from tblTenant", con);
                      DataSet ds = new DataSet();
                      da.Fill(ds);
                  }
              } 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ZYFOr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZYFOr.png" alt="enter image description here"></a></p>
  
  <p>Edit:</p>
  
  <p><a href="https://i.stack.imgur.com/THPRh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/THPRh.png" alt="enter image description here"></a></p>