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?
Asked
Active
Viewed 1,571 times
0
-
Yes, it will throw on error conditions - this will be detailed in the MSDN pages for the method. – Alex K. Oct 28 '14 at 16:33
-
Set it up in a try...catch...finally block. In the catch block set your exception handling, and close the connection in the finally block. – Tim Oct 28 '14 at 17:49
1 Answers
2
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.

Joel Coehoorn
- 399,467
- 113
- 570
- 794