當我點擊按鈕,只有我的第一個查詢得到執行。第二個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