G
gnewsgroup
You know, a SqlConnection object, a SqlCommand object, a SqlDataReader
object and many other data access objects, have a Close() method and a
Dispose() method.
What are their differences?
Q1: Should we call both Close() and Dispose() on an object in finally
block? If not, then which one should we call and why?
Q2: If it makes sense to call both, does the order of calling them
matter?
Q3: Does the order of calling either Close() or Dispose() or both
matter on a SqlConnection object, a SqlCommand object which contains
this connection, a SqlDataReader object which is a result of
ExecuteReader of this SqlCommand object?
Thank you.
object and many other data access objects, have a Close() method and a
Dispose() method.
What are their differences?
Q1: Should we call both Close() and Dispose() on an object in finally
block? If not, then which one should we call and why?
Q2: If it makes sense to call both, does the order of calling them
matter?
Q3: Does the order of calling either Close() or Dispose() or both
matter on a SqlConnection object, a SqlCommand object which contains
this connection, a SqlDataReader object which is a result of
ExecuteReader of this SqlCommand object?
Thank you.