ExecuteNonQuery Query

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?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

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
 
S

Steven Nagy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top