ExecuteNonQuery Query

  • Thread starter Thread starter Fred Chateau
  • Start date Start date
F

Fred Chateau

This is a two part question.

(1) After opening a connection and calling ExecuteNonQuery within a
transaction in .NET 2.0, is any resource cleanup still required in a finally
block?

(2) My code calls the OpenRowset Bulk provider using a command query string,
but it seemed ExecuteNonQuery was the proper method to call because nothing
is returned. Is this correct?
 
Fred said:
(1) After opening a connection and calling ExecuteNonQuery within a
transaction in .NET 2.0, is any resource cleanup still required in a finally
block?

You still need to close the connection.

Arne
 
1) Close your connection again and dispose your command object
2) Not sure about that exact SQL, but ExecuteNonQuery is best when you
don't need a result set. It does return the number of rows affected
however, which you can choose not to assign if you so wish.
 
Back
Top