title: How can I get a username and password from my database in C#?
body: <p>I have the following code in my <code>btn_click</code> event:</p>
  
  <pre><code>Sqlconnection con = new Sqlconnection("server=.;database=bss;user id=ab;pwd=ab");
  con.open();
  SqlCommand cmd = new Sqlcommand("select * from login where username='" 
  + txt4name.Text + "' and pwd='" + txt4pwd.Text + "'", con);
  
  SqlDataReader reader = cmd.execute Reader();
  </code></pre>
  
  <p>Where <code>login</code> is the table and <code>username</code> and <code>pwd</code> are its fields. After this code all the values are stored in the <code>reader</code> object. I want to store <code>username</code> and <code>pwd</code> in the separate variables. </p>
  
  <p>How can I accomplish this?</p>