将 dbFailOnError 添加到 CurrentDb.Execute 无法更新表 [英] Adding dbFailOnError to CurrentDb.Execute fails to update table

查看:61
本文介绍了将 dbFailOnError 添加到 CurrentDb.Execute 无法更新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长期潜伏者,第一次发帖.

Long time lurker, first time poster.

我有一个通过 5.1 ODBC 驱动程序连接到 Access 2010 的 mySQL 表.我正在尝试更新 mySQL 表并奇怪地在 CurrentDb.Execute strSQL 的末尾添加 dbFailOnError 阻止表更新但不会引发任何错误.我的 VBA 编辑器设置为中断所有错误.例程中的所有错误处理均已注释以供测试.

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.

如果我使用 CurrentDb.Execute strSQLDoCmd.RunSQL strSQL,表会更新.另外,mySQL 表有一个索引.

If I use CurrentDb.Execute strSQL or DoCmd.RunSQL strSQL, the table updates. Also, the mySQL table has an index.

SQL 字符串:

strSQL = "UPDATE clients
SET [DateLastAccessed] = " & lngDateAccessed & ",
[CountAccess] = " & intCountAccessed & "
WHERE [SerialHDD] = '" & strGetHDD & "' ;"

非常感谢任何帮助.

推荐答案

"CurrentDb.Execute strSQL 末尾添加 dbFailOnError 会阻止表更新但不会抛出任何错误"

"adding dbFailOnError at the end of CurrentDb.Execute strSQL prevents the table from updating but does not throw any error"

如果 SetWarnings 已关闭,则可能无法在没有可见错误的情况下进行更新.检查在执行更新语句之前立即打开 SetWarnings 时是否得到不同的结果.

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 

这篇关于将 dbFailOnError 添加到 CurrentDb.Execute 无法更新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆