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?
我正在研究一个使用ODBC来更新DB2 Table的VB6可执行文件。当尝试更新不存在的行时,程序不会像预期的那样抛出错误。为什么会这样?
objAdoConn.Execute("Update T1234 Set A = 'X' Where B = 'y'");
3 个解决方案
#1
Because this is a valid SQL statement that results in "0 rows affected". Which is success.
因为这是一个有效的SQL语句,导致“0行受影响”。哪个是成功的。
#2
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的角度来看,该命令没有任何问题 - 它只是不更新任何东西,这是一个非常有效的结果。
#3
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:
其他答案是正确的:它是一个有效的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!"
#1
Because this is a valid SQL statement that results in "0 rows affected". Which is success.
因为这是一个有效的SQL语句,导致“0行受影响”。哪个是成功的。
#2
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的角度来看,该命令没有任何问题 - 它只是不更新任何东西,这是一个非常有效的结果。
#3
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:
其他答案是正确的:它是一个有效的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!"