title: Connection string in C# Window application
body: <p>In window application, i am trying to work with database, how to write connection string in app.config. The below is connection string in app.config</p>
  
  <pre><code>&lt;configuration&gt;
   &lt;appSettings &gt;
    &lt;add key ="mycon" 
        value ="server=192*****;database=*****;
        uid=**;pwd=*****;"/&gt;
  &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Code to connect database:</p>
  
  <pre><code>  SqlConnection con = new SqlConnection(
     ConfigurationSettings.AppSettings["mycon"].ToString()); con.Open(); 
    SqlCommand cmd = new SqlCommand("Usp_chat_login", con);
    cmd.CommandType = CommandType.StoredProcedure ;
    cmd.Parameters.Add("@userid", SqlDbType.VarChar, 20);
     cmd.Parameters["@userid"].Value = textBox1.Text;
    cmd.Parameters.Add("@password", SqlDbType.VarChar, 20);
    cmd.Parameters["@password"].Value = textBox2.Text;
    int reslt =  cmd.ExecuteNonQuery();  con.Close();
    if (reslt &gt; 0)
      {
         MessageBox.Show("Yes");
      } 
    else
       {
            MessageBox.Show("No");
  
       }
  </code></pre>
  
  <p>Every time i am getting <code>reslt=-1</code>, even if i pass correct credentials </p>