private void goodsFrame_Load(object sender, EventArgs e) { string constring = "datasource=localhost;port=3306;username=root;password=1234"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand auth = new MySqlCommand("SELECT * FROM sporthit.сотрудники WHERE логин_сотрудника = '" + Convert.ToString("admin") + "' AND пароль = '" + Convert.ToString("1234") + "'",conDataBase); conDataBase.Open(); MySqlDataReader rd = auth.ExecuteReader(); //rd.Read(); try { //auth.ExecuteNonQuery(); // if (rd.Read()) { MessageBox.Show(String.Format("Login: {0}, Password: {1}", rd.GetString("логин_сотрудника")), rd.GetString("пароль")); } else { MessageBox.Show("Неправильный логин или пароль!", "Ошибка авторизации"); } rd.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } add.BackgroundImage = Properties.Resources.addButton; remove.BackgroundImage = Properties.Resources.removeButton; } 

It is necessary to select from the database a line with the name admin and password 1234, I don’t really understand programming, I count on your help, thank you in advance!

  • And what help is needed, you have not written ... We see the code, which somehow has to work, but what exactly is it impossible for you? - EvgeniyZ
  • MessageBox.Show (String.Format ("Login: {0}, Password: {1}", rd.GetString ("employee_name")), rd.GetString ("password")); In this line, when I launch the program I write that with indexing a problem, I don’t know how to solve it - Alexander Monakhov
  • Or just tell me how you can write the code so that the line with the above names is taken and tested ... If the user has logged in as an admin, then he has certain buttons, and if, like another user, these buttons are hidden, respectively Alexander Monakhov

0