Does the using statement really call the close method when used with a database connection object? The MSDN documentation says it ensures that the Dispose method is called but makes no mention of close. I see posts on Stack Overflow where people say that it does both. Does someone have a concrete answer one way or another on this from Microsoft or other solid proof that it does?
Here is the "Dispose" method of the SqlConnection class:
protected override void Dispose(bool disposing)
{
if (disposing)
{
this._userConnectionOptions = null;
this._poolGroup = null;
this.Close();
}
this.DisposeMe(disposing);
base.Dispose(disposing);
}
As you can see, it does indeed call Close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With