ZeroEffect
Well-known member
I am trying to add a record to my access database for the application I am building. I can connect and display data from the DB but when use my code to add a row I get this error. "Syntax error in INSERT INTO statement." My ID row is auto incrementing this might be the problem. The code I using is posted below. Thanks for your help.
ZeroEffect
ZeroEffect
Code:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim cb As New OleDb.OleDbCommandBuilder(daEvents)
Dim dsNewRow As DataRow
dsNewRow = dsEvents.Tables("events").NewRow()
dsNewRow.Item("ID") = vbNull This is Auto incrementing in Access, Possible issue here
dsNewRow.Item("EventName") = tbEventName.Text
dsNewRow.Item("Command") = tbCommand.Text
dsNewRow.Item("Time") = dtpTime.Text
dsNewRow.Item("Days") = strSu & strM & strT & strW & strR & strF & strSa
dsEvents.Tables("events").Rows.Add(dsNewRow)
daEvents.Update(dsEvents, "events")
MsgBox("New Record added to the Database")
End Sub