ODBC 命令不会引发错误
我正在开发一个 VB6 可执行文件,它使用 ODBC 来更新 DB2 表。 当尝试更新不存在的行时,程序不会像预期的那样抛出错误。 为什么会出现这种情况呢?
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'");
I'm working on a VB6 executable that uses ODBC to update a DB2 Table. When trying to update a row that does not exist the program does not throw an error as would be expected. Why would this happen?
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为这是一条有效的 SQL 语句,结果是“0 rows受影响”。 这就是成功。
Because this is a valid SQL statement that results in "0 rows affected". Which is success.
从 SQL 的角度来看,该命令没有任何问题 - 它只是不更新任何内容,这是一个完全有效的结果。
From a SQL point of view, there is nothing wrong with that command - it just doesn't update anything, which is a perfectly valid outcome.
其他 答案是正确的:这是一条有效的 SQL 语句,不会影响任何记录。 如果您想了解有多少记录受到影响,请使用可选的 RecordsAffected 参数如下所示:
The other answers are correct: it's a valid SQL statement that just doesn't affect any records. If you want to know how many records are affected, use the optional RecordsAffected parameter like this: