ODBC 命令不会引发错误

发布于 2024-07-24 04:30:04 字数 175 浏览 0 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最后的乘客 2024-07-31 04:30:04

因为这是一条有效的 SQL 语句,结果是“0 rows受影响”。 这就是成功。

Because this is a valid SQL statement that results in "0 rows affected". Which is success.

濫情▎り 2024-07-31 04:30:04

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

聊慰 2024-07-31 04:30:04

其他 答案是正确的:这是一条有效的 SQL 语句,不会影响任何记录。 如果您想了解有多少记录受到影响,请使用可选的 RecordsAffected 参数如下所示:

Dim n As Long
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'", n)
If n=0 Then MsgBox "No records affected!"

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:

Dim n As Long
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'", n)
If n=0 Then MsgBox "No records affected!"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文