DbCommand.ExecuteNonQuery error handling

1.6k Views Asked by At

When I use the DbCommand.ExecuteNonQuery() in .net, it will return a scalar. Is that the only information I will get from this command? Or is there also an exception, if for example the command is wrong, or there is a timeout or something else?

1

There are 1 best solutions below

0
Joel Coehoorn On BEST ANSWER

If the command times out, or if you have bad sql, ExecuteNonQuery() will throw an exception. The return value from the method is the number of rows effected.

The docs on DbCommand itself are sparse on this, but if you look at some of the individual providers for specific kinds of database, it becomes more clear.