Возникает ошибка your MySQL server version for the right syntax to use near ''users' WHERE 'login' = '@uL' AND 'password' = '@uP'' at line 1"
private void lodButton_Click(object sender, EventArgs e)
{
String loginUser = login.Text;
String passUser = password.Text;
DB db = new DB();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM 'users' WHERE 'login' = '@uL' AND 'password' = '@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)
MessageBox.Show("Yes");
else
MessageBox.Show("no");
}
Ответы (1 шт):
Автор решения: crow
→ Ссылка
private void lodButton_Click(object sender, EventArgs e)
{
String loginUser = login.Text;
String passUser = password.Text;
DB db = new DB();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `password` = @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)
MessageBox.Show("Yes");
else
MessageBox.Show("no");
}