0

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

leppie
  • 115,091
  • 17
  • 196
  • 297
Phillip
  • 141
  • 8

1 Answers1

1

  • 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);
    

  • andrei.ciprian
    • 2,895
    • 1
    • 19
    • 29