Hai All,
I got strange Error. Syntax error in update stmt. Same query is running in Access.
I use same routine for all update stmt all are working only this one is working.
Please help to ressolve
VB Code
lsSql = ""
lsSql = "Update vehiclemaster set regno ='" & TxtRegnno.Text & "',"
lsSql = lsSql & " VehicleType='" & CbovechType.Text & "',"
lsSql = lsSql & " dateofregn ='" & CStr(Format(DTregnDate.Value, "dd/MM/yyyy"
) & "',"
lsSql = lsSql & " placeofregn ='" & TxtRto.Text & "',"
lsSql = lsSql & " roadtaxfrom ='" & CStr(Format(DTroadtaxfrom.Value, "dd/MM/yyyy"
) & "',"
lsSql = lsSql & " roadtaxto ='" & CStr(Format(DTroadtaxto.Value, "dd/MM/yyyy"
) & "',"
lsSql = lsSql & " ownername ='" & TxtOwner.Text & "',"
lsSql = lsSql & " zone ='" & TxtZone.Text & "',"
lsSql = lsSql & " regnrenew ='" & CStr(Format(DTRtoRen.Value, "dd/MM/yyyy"
) & "'"
lsSql = lsSql & " where vechid =" & Val(TxtVehid.Text)
Call update(lsSql)
Public Function update(lsSql As String) As Boolean
On Error GoTo DBErr
Dim conn As Object
Dim cmd As New ADODB.Command
Dim lngRtn As Long
'On Error GoTo UPDATEERR
nthExecute = True
Debug.Print lsSql
Set conn = New ADODB.Connection
'Dim conn As ADODB.Connection
With conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open App.Path & "\calltaxi.mdb"
End With
cmd.ActiveConnection = conn
cmd.CommandText = lsSql
cmd.Execute lsSql, lngRtn, adCmdText
Set cmd = Nothing
Set conn = Nothing
Exit Function
DBErr:
MsgBox Err.Description, vbCritical + vbOKOnly, "Error Message"
nthExecute = False
'Err.Raise Err.Number, Err.Source, Err.Description
End Function
------------------------------------------------
Data Base Fields
field name DataType Required Primary key
-----------------------------------------------------------
vechileid number yes yes
regno TEXT YES
vehicleType text yes
dateofregn text no
placeofregn text no
roadtaxfrom text no
roadtaxto text no
ownername text no
zone text no
regnnew text no
Thanks and regrs
I got strange Error. Syntax error in update stmt. Same query is running in Access.
I use same routine for all update stmt all are working only this one is working.
Please help to ressolve
VB Code
lsSql = ""
lsSql = "Update vehiclemaster set regno ='" & TxtRegnno.Text & "',"
lsSql = lsSql & " VehicleType='" & CbovechType.Text & "',"
lsSql = lsSql & " dateofregn ='" & CStr(Format(DTregnDate.Value, "dd/MM/yyyy"
lsSql = lsSql & " placeofregn ='" & TxtRto.Text & "',"
lsSql = lsSql & " roadtaxfrom ='" & CStr(Format(DTroadtaxfrom.Value, "dd/MM/yyyy"
lsSql = lsSql & " roadtaxto ='" & CStr(Format(DTroadtaxto.Value, "dd/MM/yyyy"
lsSql = lsSql & " ownername ='" & TxtOwner.Text & "',"
lsSql = lsSql & " zone ='" & TxtZone.Text & "',"
lsSql = lsSql & " regnrenew ='" & CStr(Format(DTRtoRen.Value, "dd/MM/yyyy"
lsSql = lsSql & " where vechid =" & Val(TxtVehid.Text)
Call update(lsSql)
Public Function update(lsSql As String) As Boolean
On Error GoTo DBErr
Dim conn As Object
Dim cmd As New ADODB.Command
Dim lngRtn As Long
'On Error GoTo UPDATEERR
nthExecute = True
Debug.Print lsSql
Set conn = New ADODB.Connection
'Dim conn As ADODB.Connection
With conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open App.Path & "\calltaxi.mdb"
End With
cmd.ActiveConnection = conn
cmd.CommandText = lsSql
cmd.Execute lsSql, lngRtn, adCmdText
Set cmd = Nothing
Set conn = Nothing
Exit Function
DBErr:
MsgBox Err.Description, vbCritical + vbOKOnly, "Error Message"
nthExecute = False
'Err.Raise Err.Number, Err.Source, Err.Description
End Function
------------------------------------------------
Data Base Fields
field name DataType Required Primary key
-----------------------------------------------------------
vechileid number yes yes
regno TEXT YES
vehicleType text yes
dateofregn text no
placeofregn text no
roadtaxfrom text no
roadtaxto text no
ownername text no
zone text no
regnnew text no
Thanks and regrs