Reputation: 31848
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'");
Upvotes: 0
Views: 310
Reputation: 30408
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!"
Upvotes: 2
Reputation: 78183
Because this is a valid SQL statement that results in "0 rows affected". Which is success.
Upvotes: 3
Reputation:
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.
Upvotes: 3