How can I retrieve or display a name from a MySQL database? I have a database table where the columns are fID, USERNAME, PASSWORD and NAME
. I am using Form 1 as a log-in form. Now I want to display the name of the user on my Form 2 Label. How can I do that?
I'm stuck here:
void log_in_btn_Click(object sender, EventArgs e)
{
try
{
RF.openConnection("");
RF.selectCommand("SELECT * FROM sign_up_table WHERE USERNAME = '" + txt_Username.Text + "' AND PASSWORD = '" + txt_Password.Text + "'");
if (RF.result.Rows.Count == 1)
{
this.Visible = false;
//here i want to display the name of the user but i dont know how so I'm just displaying the username.
frm2.lbl_users_name.Text = txt_Username.Text;
frm2.ShowDialog();
}
else
{
MessageBox.Show("Incorrect\nUsername or \nPassword!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
RF.closeConnection("");
}
catch (NullReferenceException ex)
{
MessageBox.Show(ex.Message);
}
}