Answer the question
In order to leave comments, you need to log in
How to make authorization with different access rights?
I use MySQL, there is information about users. The last field contains permissions. It is necessary that, depending on the position, different forms open. Authorization code:
string loginUser = loginField.Text;
string passUser = passField.Text;
DB db = new DB();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `pass` = @uP", db.getConnection());
command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;
adapter.SelectCommand = command;
adapter.Fill(table);
if (table.Rows.Count > 0)
{
this.Hide();
MainForm mainForm = new MainForm();
mainForm.Show();
}
else
MessageBox.Show("Неверный логин или пароль");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question