Phillip
Phillip

Reputation: 151

Does ExecuteReader(timeout) method terminate process and close connection?

When using ExecuteReader(timeout) method to execute a SP, does it terminate process and close connection?

Upvotes: 0

Views: 350

Answers (1)

andrei.ciprian
andrei.ciprian

Reputation: 3025

  • System.Data.Common.DbCommand and the more specialized System.Data.SqlClient.SqlCommand do not contain an overload with a timeout parameter. There is the parameterless ExecuteReader method and an overload with a CommandBehavior parameter. Some other db providers may have this overload, even though I guess there is no need for that since you can use the CommandTimeout property from the base class System.Data.Common.DbCommand abstract base class.
  • I guess the behavior you are looking for is:

    System.Data.Common.DbCommand cmd = null;
    // init command
    System.Data.Common.DbDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
    

  • Upvotes: 1

    Related Questions