Correct your code like
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
' Assign your command to data adapter
da.InsertCommand = cb.GetInsertCommand
da.UpdateCommand = cb.GetUpdateCommand
da.DeleteCommand = cb.GetDeleteCommand
'This statement force to change row state
ds.Tables("StudentContacts").Rows(inc).BeginEdit()
ds.Tables("StudentContacts").Rows(inc).Item(0) =
txtBoxStudentRef.Text
ds.Tables("StudentContacts").Rows(inc).Item(1) =
CmboBoxTitle.Text
ds.Tables("StudentContacts").Rows(inc).Item(2) =
txtBoxFullName.Text
ds.Tables("StudentContacts").Rows(inc).Item(3) =
dobpicker.Text
' I think your another error present here
ds.Tables("StudentContacts").Rows(inc).Item(4) =
CmboBoxGender.Text
'So replace the above code & insert the following code
If (CmboBoxGender.Text="Male") Then
ds.Tables("StudentContacts").Rows(inc).Item(4) =True
Else
ds.Tables("StudentContacts").Rows(inc).Item(4) =False
ds.Tables("StudentContacts").Rows(inc).Item(5) =
txtBoxAddress.Text
ds.Tables("StudentContacts").Rows(inc).Item(6) =
txtBoxAddress1.Text
ds.Tables("StudentContacts").Rows(inc).Item(7) =
txtBoxCity.Text
ds.Tables("StudentContacts").Rows(inc).Item(8) =
txtBoxPostcode.Text
ds.Tables("StudentContacts").Rows(inc).Item(9) =
txtBoxHmeNmber.Text
ds.Tables("StudentContacts").Rows(inc).Item(10) =
txtBoxMobNmber.Text
ds.Tables("StudentContacts").Rows(inc).Item(11) =
txtBoxEmail.Text
ds.Tables("StudentContacts").Rows(inc).Item(12) =
txtBoxCourseappfor.Text
ds.Tables("StudentContacts").Rows(inc).Item(13) =
cmboBoxFees.Text
ds.Tables("StudentContacts").Rows(inc).Item(14) =
cmboBoxEntrytest.Text
ds.Tables("StudentContacts").Rows(inc).Item(15) =
txtBoxNotes.Text
ds.Tables("StudentContacts").Rows(inc).EndEdit()
da.Update(ds, "StudentContacts")
End Sub
2009/4/19 bella_fonte <[email protected]>
>
> Hi guys,
>
> I am designing a program on VB 2008 and I am getting the following
> error:
>
> OleDBException was unhandled: Syntax error (missing operator) in query
> expression '((Student Ref = ?) AND ((? = 1 AND Title IS NULL) OR
> (Title = ?)) AND ((? = 1 AND Full Name IS NULL) OR (Full Name = ?))
> AND ((? = 1 AND Date of Birth IS NULL) OR (Date of Birth = ?)) AND ((?
> = 1 AND Gender IS NULL) OR (Gender = ?)) AND ((? = 1 AND Addres'.
>
> In my database, my fields are full with the details so I dont know why
> it is saying NULL.
>
> Here is my code:
>
> Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnUpdate.Click
> Dim cb As New OleDb.OleDbCommandBuilder(da)
>
> ds.Tables("StudentContacts").Rows(inc).Item(0) =
> txtBoxStudentRef.Text
> ds.Tables("StudentContacts").Rows(inc).Item(1) =
> CmboBoxTitle.Text
> ds.Tables("StudentContacts").Rows(inc).Item(2) =
> txtBoxFullName.Text
> ds.Tables("StudentContacts").Rows(inc).Item(3) =
> dobpicker.Text
> ds.Tables("StudentContacts").Rows(inc).Item(4) =
> CmboBoxGender.Text
> ds.Tables("StudentContacts").Rows(inc).Item(5) =
> txtBoxAddress.Text
> ds.Tables("StudentContacts").Rows(inc).Item(6) =
> txtBoxAddress1.Text
> ds.Tables("StudentContacts").Rows(inc).Item(7) =
> txtBoxCity.Text
> ds.Tables("StudentContacts").Rows(inc).Item(8) =
> txtBoxPostcode.Text
> ds.Tables("StudentContacts").Rows(inc).Item(9) =
> txtBoxHmeNmber.Text
> ds.Tables("StudentContacts").Rows(inc).Item(10) =
> txtBoxMobNmber.Text
> ds.Tables("StudentContacts").Rows(inc).Item(11) =
> txtBoxEmail.Text
> ds.Tables("StudentContacts").Rows(inc).Item(12) =
> txtBoxCourseappfor.Text
> ds.Tables("StudentContacts").Rows(inc).Item(13) =
> cmboBoxFees.Text
> ds.Tables("StudentContacts").Rows(inc).Item(14) =
> cmboBoxEntrytest.Text
> ds.Tables("StudentContacts").Rows(inc).Item(15) =
> txtBoxNotes.Text
>
> da.Update(ds, "StudentContacts") <-error here
>
> End Sub
>
> Before this error occurred, I had another error with the "da.Update
> (ds, "StudentContacts"). The error is, String was not recognized as a
> valid Boolean.Couldn't store <Yes (details in comment box)> in
> Interview/Entry Test Needed? (Details in comment box) Column.
> Expected type is Boolean.
>
> Hope you can help.
>
--
Regards
*******************
*C.Arun Kumar *
*******************