title: C# : how to get value from specific column from SQL Server and store into variable
body: <p>I want to ask how to store the full name (from database @3) of the user into the variable <code>fname</code>.</p>
  
  <pre><code>SqlDataReader rdr = cm.ExecuteReader();
  string sql = "Select * from Login where Username like'" + txtUser.Text + "'and password like'" + txtPass.Text + "'";
  
  cm = new SqlCommand(sql, cn);
  dr = cm.ExecuteReader();
  
  dr.Read();
  
  if (dr.HasRows)
  {
      cn.Close();
      AutoClosingMessageBox.Show("Access Granted. Welcome " + txtUser.Text + "!", "Successfully Login.", 400);
  
      cn.Open();
      UserID = cm.ExecuteScalar().ToString();
  
      //fname = ;
      Form1 frmMain = new Form1();
      frmMain.pass(UserID);
      frmMain.Show();
      this.Hide();
      //...
  }
  </code></pre>
  
  <p>My database : @0 = ID, @1 = Username, @2 = Password, @3 = full name, @4 = binary image. I can't post photo :( ></p>
  
  <p>If anyone also knows how to convert the binary into a picture, that would help me a lot thanks.</p>