tags:

views:

61

answers:

2

I keep getting a mismatch error for this line:

UPDATE tblLunchTime SET [End] = '06/28/2010 9:41:34 AM' WHERE Start = '06/28/2010 9:41:31 AM'

Does anyone know why?

EDIT: Rest of the code added.

'Save end time in database.
Dim strValuesQuery As String

strValuesQuery = _
    "UPDATE tblLunchTime " & _
    "SET [End] = '" & Now & "' " & _
    "WHERE Start = '" & StartTime & "' "

'Execute Query.
DoCmd.RunSQL strValuesQuery
+1  A: 

I ended up adding the pound symbol to my variable in order to allow it to be formatted in the way needed:

strValuesQuery = _
    "UPDATE tblLunchTime " & _
    "SET EndTime = #" & Now & "# " & _
    "WHERE StartTime = #" & StartTime & "#"
BioXhazard
# is the delimiter for dates in Jet/ACE SQL.
David-W-Fenton
A: 

Are you executing this query to SqlServer, oracle ?

Is same language at client side and server side ?

Using date To String and String to date needs a specific format conversion.

For oracle: EndTime = to_date('2010/01/05','yyyy/mm/dd')

this avoids language mismatch.

I use always parameters.

"UPDATE tblLunchTime SET EndTime = ? WHERE StartTime = ?" - For OleDb

Parameters avoid some errors, and also improve performance (Server caches cursors).

x77
Did you bother to read the tags?
David-W-Fenton