Y
Y
Yzurgzd2020-03-09 15:37:33
C++ / C#
Yzurgzd, 2020-03-09 15:37:33

How to make authorization with different access rights?

I use MySQL, there is information about users. 5e66375a63031230876549.jpegThe 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

1 answer(s)
C
CityCat4, 2020-03-09
@CityCat4

The language tag is missing. Will we guess?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question