Close() or Dispose()...
Interesting post from Jim Blizzard.Still the debate continue but yes agree MSDN docs are the reference.
Rory asks us (http://neopoleon.com/blog/posts/2889.aspx)
about calling Close() or Dispose() on ADO.NET objects. He went into ILDASM to see if Dispose() also calls Close(), and sure enough, it does.
And all he had to do was look in the MSDN docs. Cause we know that the MSDN docs are always right, don't we. ;)
public void SqlConnectionHereAndGone()
{
SqlConnection myConnection = new
SqlConnection("Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;");
myConnection.Open();
//Calling Dispose also calls SqlConnection.Close.
myConnection.Dispose();
}
Look at that comment in the sample code (straight from MSDN): "Calling Dispose also calls SqlConnection.Close."
Amazing. :)