问题
Long time lurker, first time poster.
I have a mySQL table connected to Access 2010 via the 5.1 ODBC driver. I am trying to update the mySQL table and curiously adding dbFailOnError at the end of CurrentDb.Execute strSQL prevents the table from updating but does not throw any error. My VBA editor is set to break on all errors. All error handling in the routine has been commented for testing.
If I use CurrentDb.Execute strSQL or DoCmd.RunSQL strSQL, the table updates. Also, the mySQL table has an index.
SQL string:
strSQL = "UPDATE clients
SET [DateLastAccessed] = " & lngDateAccessed & ",
[CountAccess] = " & intCountAccessed & "
WHERE [SerialHDD] = '" & strGetHDD & "' ;"
Any help is much appreciated.
回答1:
"adding dbFailOnError
at the end of CurrentDb.Execute strSQL
prevents the table from updating but does not throw any error"
That could fail to update without a visible error if SetWarnings
has been switched off. Check whether you get a different outcome when switching SetWarnings
on immediately before executing the update statement.
DoCmd.SetWarnings True
CurrentDb.Execute strSQL, dbFailOnError
来源:https://stackoverflow.com/questions/13943753/adding-dbfailonerror-to-currentdb-execute-fails-to-update-table