I am using update query statment but is not working for this code

Dim myConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../lms/DBLMS.mdb")
        Dim item As Integer
        myConn.Open()
        myComm = New OleDbCommand("UPDATE tblVehicles SET Vehicle_Type = " & cboVehicle_Type.Text & ", Vehicle_Model = " & txtVehicle_Model.Text & ", Plate_No = " & txtPlate_No.Text & ", Date_Acquired = " & dtpDate.Text & ", WHERE Vehicle_Id = " & txtVehicle_Id.Text & ")", myConn)
        item = myComm.ExecuteNonQuery()
        myConn.Close()

ERROR - Syntax error (missing operator) in query expression '02/09/2011 01:21 PM'.

Edited 5 Years Ago by TIP.Synergy: i forgot to insert [CODE]

TIP.Synergy
remove the integer (item ) decleared
ie item = myComm.ExecuteNonQuery()
make it as
myComm.ExecuteNonQuery()
and try

Edited 5 Years Ago by DONPAWPAW: correct

Use Parameters.

Dim myConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../lms/DBLMS.mdb")

Dim item As Integer
myComm = New OleDbCommand("UPDATE tblVehicles SET Vehicle_Type =@p1, Vehicle_Model =@p2,Plate_No =@p3,Date_Acquired =@p4 WHERE Vehicle_Id = @p5", myConn)


myComm.Parameters.AddWithValue("@p1",cboVehicle_Type.Text)
myComm.Parameters.AddWithValue("@p2",txtVehicle_Model.Text)
myComm.Parameters.AddWithValue("@p3",txtPlate_No.Text)
myComm.Parameters.AddWithValue("@p4",dtpDate.Value)
myComm.Parameters.AddWithValue("@p5",txtVehicle_Id.Text)

myConn.Open()
item=myComm.ExecuteNonQuery()
myConn.Close()
Comments
showing the way it should be done.

Use Parameters.

Dim myConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../lms/DBLMS.mdb")

Dim item As Integer
myComm = New OleDbCommand("UPDATE tblVehicles SET Vehicle_Type =@p1, Vehicle_Model =@p2,Plate_No =@p3,Date_Acquired =@p4 WHERE Vehicle_Id = @p5", myConn)


myComm.Parameters.AddWithValue("@p1",cboVehicle_Type.Text)
myComm.Parameters.AddWithValue("@p2",txtVehicle_Model.Text)
myComm.Parameters.AddWithValue("@p3",txtPlate_No.Text)
myComm.Parameters.AddWithValue("@p4",dtpDate.Value)
myComm.Parameters.AddWithValue("@p5",txtVehicle_Id.Text)

myConn.Open()
item=myComm.ExecuteNonQuery()
myConn.Close()

Thx to you Mr.adatapost, It works, but i don't know which is better parameter or non parameter?
but finally, i decided to use parameters

'copy and past and it will work perfectly
'you eliminated the single quote in yor query
'remove the variable decleared (Dim item As Integer)

Dim myConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../lms/DBLMS.mdb")   
   
     myConn.Open()     

   myComm = New OleDbCommand("UPDATE tblVehicles SET Vehicle_Type = '" & cboVehicle_Type.Text & "', Vehicle_Model = '" & txtVehicle_Model.Text & "', Plate_No = '" & txtPlate_No.Text & "', Date_Acquired = '" & dtpDate.Text & "', WHERE Vehicle_Id = '" & txtVehicle_Id.Text & "')", myConn) 

     
myComm.ExecuteNonQuery()   

myConn.Close()
This question has already been answered. Start a new discussion instead.