The program I'm writing (in vb.net) is supposed to be loading values from text boxes into a database. However, when I click "Save", at first nothing at all happened. No error, no notification, nothing. So I traced it using breakpoints, and it got to:
daTraining.Update(dsTraining, "Training")
and just stopped. So I put in a try/catch, and now when I hit save I get
System.Data.OleDB.OledgException (0x80040E14): Syntax error in INSERT INTO statement.
I'm confused on how to troubleshoot this or what the issue might be.
The Code
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Try
Dim cb As New OleDb.OleDbCommandBuilder(daTraining)
Dim dsNewRow As DataRow
dsNewRow = dsTraining.Tables("Training").NewRow
dsNewRow.Item("ID") = txtTrainingID.Text
dsNewRow.Item("Ranch") = cbRanches.Text
dsNewRow.Item("Location") = txtLocation.Text
dsNewRow.Item("Date") = mtbDate.Text
dsNewRow.Item("StartTime") = mtbStartTime.Text
dsNewRow.Item("FinishTime") = mtbFinishTime.Text
dsNewRow.Item("Crew") = txtCrews.Text
dsNewRow.Item("Supervisor") = txtSupervisor.Text
dsNewRow.Item("Foreperson") = txtForeperson.Text
dsNewRow.Item("Activity") = txtActivity.Text
dsNewRow.Item("Trainer") = txtTrainer.Text
dsNewRow.Item("Topics") = txtTopics.Text
dsTraining.Tables("Training").Rows.Add(dsNewRow)
daTraining.Update(dsTraining, "Training")
MsgBox("Training Recorded")
cb.Dispose()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
daTraining.InsertCommand.CommandText. You should find that it has some kind of an error