HOW TO RETRIEVE NUMBER OF RECORDS AFFECTED

  • Thread starter Thread starter Carlos
  • Start date Start date
C

Carlos

Hi,

I am using executescalar to update a table. When testing the sql statement,
I am sending a value that does not exist in the condition. However, the
command is successful. Is there any way to know that in reality no records
were affected by the update?
(i..e I already tested for null, but that also was returned for valid
values..)

Thanks in advance,

Carlos.
 
ExecuteScalar is designed to return the first column of the first row in the
result set. Your are not supposed to run update/insert/delete statements.

Use ExecuteNonQuery.
 
Right and ExecuteNonQuery returns RecordsAffected

Dim ra as Integer
ra=cmd.ExecuteNonQuery



--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top