ODBCCommand - SQL update

  • Thread starter Thread starter Roger Cantillo
  • Start date Start date
R

Roger Cantillo

Using and ODBCCommand object, can I tell whether my update command updated
successfully without using a datareader?
 
If you execute it i.e. ExecuteNonQuery, and it does not
throw an exception, then you can assume that your command
updated successfully.

Tu-Thach
 
If that's the case, then I have a problem...

I ran an update command with bad data and it ran fine
 
What data did you insert and what do you expect to
happen? Please post code.

Tu-Thach
 
The ExecuteNonQuery Method will also return the number of records affected
by the query, which will tell you whether any records were updated
regardless of whether or not an error was thrown.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
I'm using a mySQL db. My guess is that it doesn't throw exceptions when
update command is unsuccessful.
 
That could be the case. It depends on who implements the
provider. They might decide not to throw an exception,
but returns 0 on the ExecuteNonQuery method. The
ExecuteNonQuery method will return the number of records
successfully updated.

Tu-Thach
 
Back
Top