当我点击按钮,只有我的第一个查询得到执行。第二个insert into afspraken (behandeling)
不执行。任何人都知道为什么?不执行第二个查询?
private void button1_Click(object sender, EventArgs e)
{
string insertStatement = "INSERT INTO Afspraken (Afspraakdatum) VALUES ('" + textBox23.Text + "');";
string insertStatement1 = "INSERT INTO Afspraken (Behandeling) VALUES ('" + textBox21.Text + "');";
OleDbCommand insertCommand = new OleDbCommand(insertStatement, connection);
OleDbCommand insertCommand1 = new OleDbCommand(insertStatement1, connection);
connection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
}
finally
{
connection.Close();
textBox23.Clear();
textBox21.Clear();
MessageBox.Show("Uw afspraak is gemaakt!");
}
}
谢谢你的回答,但是你的建议代码会导致以下错误:Syntax查询表达式“30-01-2016,few;”中的错误(缺少运算符) 请注意,“30-01-2016”和“few”是我的文本框中的值, – Needsomehelp
我改变了我的答案,在第一个值后缺少一个撇号,现在检查它 – Phiter
是的,它的工作原理,欣赏它! – Needsomehelp