C. Ross
C. Ross

Reputation: 31848

ODBC Command does not throw error

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

Answers (3)

MarkJ
MarkJ

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

GSerg
GSerg

Reputation: 78183

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

Upvotes: 3

anon
anon

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

Related Questions