我正在构建 vb.net-ms 访问数据库项目。在其中一个Insert
命令中,我收到"Please check the number"
指向ExecuteNonQuery
代码行的异常。
这是我的代码:
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
If cbMachine.SelectedIndex <> -1 And _
cbShift.SelectedIndex <> -1 And _
cbWdiv.SelectedIndex <> -1 And _
cbChky.SelectedIndex <> -1 And _
cbBukby.SelectedIndex <> -1 And _
cbRemarks.SelectedIndex <> -1 Then
cmdInsert.CommandText = "INSERT INTO buktab ([Booking Date],[Machine Type],[Shift],[MS Division / Ward], Chowky, [Booked By], [Site Address], [Remarks]) VALUES(" &
DateTimePicker1.Value.Date & ", '" & cbMachine.Text & "', '" & cbShift.Text & "', '" & cbWdiv.Text & "', '" & cbChky.Text & "', '" & cbBukby.Text & "', '" & cbSite.Text & "', '" & cbRemarks.Text & "');"
cmdInsert.CommandType = CommandType.Text
cmdInsert.Connection = cnnOLEDB
cmdInsert.ExecuteNonQuery()
MsgBox("Machine Booked Successfully!")
'Resetting all comboboxes
DateTimePicker1.Text = Today()
cbMachine.SelectedIndex = -1
cbShift.SelectedIndex = -1
cbWdiv.SelectedIndex = -1
cbChky.SelectedIndex = -1
cbBukby.SelectedIndex = -1
cbSite.Text = "Please Type Manually"
cbRemarks.SelectedIndex = -1
Else
MsgBox(" Please Enter the Missing Values")
End If
cmdInsert.Dispose()
End Sub
请让我知道我哪里出错了。