ExecuteNonQuery Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Chateau

    ExecuteNonQuery Query

    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?

    --
    Regards,

    Fred Chateau
    fchateauAtComca stDotNet


  • Arne Vajhøj

    #2
    Re: ExecuteNonQuery Query

    Fred Chateau wrote:
    (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

    Comment

    • Steven Nagy

      #3
      Re: ExecuteNonQuery Query

      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.


      Fred Chateau wrote:
      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?
      >
      --
      Regards,
      >
      Fred Chateau
      fchateauAtComca stDotNet

      Comment

      Working...