This is the imageСинтаксическая ошибка в UPDATE заявление (базы данных MS Access)
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "")
{
MessageBox.Show("Please Complete all Field");
}
else
{
if ((textBox3.Text == textBox4.Text) && (textBox5.Text == textBox6.Text))
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
command.CommandText = "update Table2 set username ='" + textBox2.Text + "', password ='" + textBox6.Text + "' where AID='" + aid + "'";
command.ExecuteNonQuery();
MessageBox.Show("Admin account update complete!");
connect.Close();
}
else
{
MessageBox.Show("Field dont match each other!");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox7.Text == "" || textBox8.Text == "" || textBox9.Text == "")
{
MessageBox.Show("Please Complete all Field");
}
else
{
if (textBox8.Text == textBox9.Text)
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
command.CommandText = "insert into Table2 (username,password) values('" + textBox7.Text + "','" + textBox9.Text + "')";
command.ExecuteNonQuery();
MessageBox.Show("Admin account add complete!");
connect.Close();
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
}
}
}
Я получаю ошибку синтаксиса в UPDATE
постановке на command.ExecuteNonQuery();
на обе кнопки. Я уже создал новую таблицу в моей базе данных, но все тот же. Также проверьте орфографию и все хорошее.
По-прежнему такая же ошибка. спасибо за ответ btw –
@RalphIgnacio вы должны сделать это для всех ваших запросов, это имя таблицы Table2? – mybirthname
Теперь все работает, проблема в MS Access, я создал новый столбец в той же таблице и просто передал данные. Спасибо :) –