OleDBException was unhandled.

51 views
Skip to first unread message

bella_fonte

unread,
Apr 18, 2009, 5:44:33 PM4/18/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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.

The_Fruitman

unread,
Apr 20, 2009, 9:58:29 AM4/20/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
First off, its saying that something is wrong with your SQL
statement. To help you debug we would need to see the entire SQL
statement or you can copy the whole SQL statement and run it on the
database itself and see what's wrong with it.

For your other error, if you didn't fix it yet, a Boolean field is
either true or false (yes or no in Access). It can only be true or
false with no additional information, so if you passed the string "Yes
(details in comment box)" it will fail.

ARUN KUMAR

unread,
Apr 20, 2009, 12:45:13 PM4/20/09
to DotNetDe...@googlegroups.com
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 <anna_...@yahoo.com>



--
Regards
*******************
*C.Arun Kumar *
*******************



ARUN KUMAR

unread,
Apr 20, 2009, 1:22:54 PM4/20/09
to DotNetDe...@googlegroups.com
I am forgot to say what exact reson for this error
 
 This query doesn't have paramter's
 that is query would be
((Student Ref = @StudentRef) AND ((@IsNullTiltle = 1 AND Title IS NULL) OR
(Title = @Title)) ..........
(This query contain OptimisticConcurrency)
 
This is reason to  change your code
Build the command and it assign to dataadapter
 
 

 
2009/4/19 bella_fonte <anna_...@yahoo.com>
Reply all
Reply to author
Forward
0 new messages