so i have this code which is used by a login winforms app.
String querry = "SELECT * FROM Accs WHERE email = '" + richTextBox1.Text + "' AND password = '" + richTextBox2.Text + "'";
SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
DataTable dtable = new DataTable();
sda.Fill(dtable);
if(dtable.Rows.Count > 0)
{
//the login operation is successful
email = richTextBox1.Text;
pass = richTextBox2.Text;
}
what i want to do is to take the "username" value from the same row
how can i do that?
this is my accounts table:
sql account table screenshot
>Solution :
Correct me if I’m wrong, but it seems that you are looking for
if(dtable.Rows.Count > 0)
{
//the login operation is successful
email = richTextBox1.Text;
pass = richTextBox2.Text;
username = dtable.Rows[0]["username"];
}