开发者

VB Mismatch Error

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: Re开发者_C百科st 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


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 & "#"


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜