I have a custom login form for my application, which gets the username and password from a database (MS Access). After the user selects their username and puts password and hits the login button the new form will appear. This is the login button click event I used:
OleDbCommand cmde = new OleDbCommand("SELECT * FROM Account WHERE username='"+ username.Text +"' and password='"+ passtxt.Text +"'", GetConnection());
OleDbDataReader reader = cmde.ExecuteReader();
if (reader.HasRows == true)
{
MainForm frm = new MainForm(this);
frm.Show();
this.Hide();
}
else
{
MessageBox.Show("Wrong Password!!!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
My question is how do I get the username/level which has been logged in on my new form? so I can hide some options on my form for non-admin users.