嘗試將記錄插入數據庫時出現錯誤。當插入訪問數據庫時插入錯誤C#
這裏的錯誤:
驗證碼:
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO [Booking] (TableID, BookingName, BookingNumber, BookingDate, PartySize) VALUES (@TableID, @BookingName, @BookingPhoneNumber, @BookingDate, @PartySize)";
command.Parameters.AddRange(new OleDbParameter[] {
new OleDbParameter("@TableID", textBoxResTableID.Text),
new OleDbParameter("@BookingName", textBoxResName.Text),
new OleDbParameter("@BookingPhoneNumber", textBoxResNum.Text),
new OleDbParameter("@BookingDate", DateTime.Today),
new OleDbParameter("@PartySize", textBoxResPartySize.Text)
});
command.ExecuteNonQuery();
connection.Close();
的DB:
在'insert'語句的末尾忘記';'? –
@Kilanny據我所知,這不是_have to_。 –
這可能是由於參數語法不正確。檢查這個答案http://stackoverflow.com/a/5894003/4795214 –