title: How can i pass a value to a label from a database based on the users details
body: <p>I have a login table with each user having different roles eg Staff, Admin.<br>
  I can have the user log in sucessfully with their username displaying between pages on the console application.<br>
  I am trying to Add in a new label  beside the username label so upon login the next page will have something like this  Admin: Johny  or Staff: Bob</p>
  
  <p>What i have tried to do is Change the query to:</p>
  
  <blockquote>
    <p>"SELECT Role From User_Table WHERE eb_number='" + usernametxt.Text + "' and Password = '" + textBox1.Text + "'",con); </p>
  </blockquote>
  
  <p>but this does not work either.</p>
  
  <pre><code>private void loginbtn_Click(object sender, EventArgs e)
  {
  
      //GRANT ACCESS TO THE DATABASE WITH USERNAME AND PASSWORD WHICH IS STORED IN THE DATABASE.
      SqlConnection con = new SqlConnection(conString);
      con.Open();
      if (con.State==System.Data.ConnectionState.Open)
      {
          SqlDataAdapter sda = new SqlDataAdapter("SELECT Count(*) From User_Table WHERE eb_number='" + usernametxt.Text + "' and Password = '" + textBox1.Text + "'",con);
          DataTable dt = new DataTable();
          sda.Fill(dt);
          if (dt.Rows[0][0].ToString() == "1")
          {
              this.Hide();
  
              Main ss = new Main(usernametxt.Text); //usernametxt is passed in to prevent error
              ss.Show();
              MessageBox.Show("Logged in sucessfully");
  
          }
          else
          {
              MessageBox.Show("Incorrect Username/Password Combination. Try Again");
          }
      }
  }
  </code></pre>
  
  <p>Main.cs</p>
  
  <pre><code>    public Main(string Username/*, string Role*/) //passing username values 
      {
          InitializeComponent();
          Username_lbl.Text = Username;  //Displaying  username 
          //Main_Role_lbl.Text = Role;
  </code></pre>
  
  <p>At he minute my code Just lets me log in and out reading the username and passwords.  I am unsure if i can add in to search for the Role for the username in the SQL query this way?  What i expected it the code to do was have a login like Admin: Johny or Staff: Bob </p>