DanielG
DanielG

Reputation: 1237

DbCommand.ExecuteNonQuery error handling

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?

Upvotes: 0

Views: 1742

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 416111

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.

Upvotes: 2

Related Questions