Hi im trying to add a new record to a table in an access database
The table is called tblLessons, and has the following fields:
LessonNo(PK) autonumber
Location: text
Instructor: text
Date: Date/time
ClientName: text
PhoneNo: text
i am adding a new record from a form which will contain the information i want to input:
location, instructor, date, client name, and his/her phone number
my code seems to be ok but im getting the following error
Unhandled Exception: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
with regards my second last line of code:
this is the code ive used
Dim objRow As DataRow
Dim LessonDate As Date
LessonDate = dtpLessons.Value()
Retrieve()
'Create a new DataRow object for this table
objRow = objDataSet.Tables("tblLessons").NewRow()
'Edit Each Field value
objRow.Item("LessonNo") = InputBox("Please Enter Lesson Number")
objRow.Item("Location") = cboLocation.SelectedItem
objRow.Item("Instructor") = cboInstructor.SelectedItem
objRow.Item("Date") = LessonDate
objRow.Item("ClientName") = txtName.Text
objRow.Item("PhoneNo") = Val(txtPhone.Text)
'Officially add the DataRow to our table
objDataSet.Tables("tblLessons").Rows.Add(objRow)
objLessonDA.Update(objDataSet, "tblLessons")
objDataSet.AcceptChanges()
The code highlighted in red is the one that i am having problems with if you can help please do
Thanks
The table is called tblLessons, and has the following fields:
LessonNo(PK) autonumber
Location: text
Instructor: text
Date: Date/time
ClientName: text
PhoneNo: text
i am adding a new record from a form which will contain the information i want to input:
location, instructor, date, client name, and his/her phone number
my code seems to be ok but im getting the following error
Unhandled Exception: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
with regards my second last line of code:
this is the code ive used
Dim objRow As DataRow
Dim LessonDate As Date
LessonDate = dtpLessons.Value()
Retrieve()
'Create a new DataRow object for this table
objRow = objDataSet.Tables("tblLessons").NewRow()
'Edit Each Field value
objRow.Item("LessonNo") = InputBox("Please Enter Lesson Number")
objRow.Item("Location") = cboLocation.SelectedItem
objRow.Item("Instructor") = cboInstructor.SelectedItem
objRow.Item("Date") = LessonDate
objRow.Item("ClientName") = txtName.Text
objRow.Item("PhoneNo") = Val(txtPhone.Text)
'Officially add the DataRow to our table
objDataSet.Tables("tblLessons").Rows.Add(objRow)
objLessonDA.Update(objDataSet, "tblLessons")
objDataSet.AcceptChanges()
The code highlighted in red is the one that i am having problems with if you can help please do
Thanks