Possible duplicate:Do I need to close DbConnection if the use clause is used?
Does the OledbConnection.Dispose()connection close ?
OledbConnection.Dispose()
I know what I'm SqlConnectiondoing, but what about OledbConnection?
SqlConnection
OledbConnection
Yes, it also does.
Source: OleDbConnection.Dispose Method (Boolean)
The Dispose method calls Close and removes the OleDbConnection from the connection pool.
For more information, see the Remarkslink to link section to learn about the release of both managed and unmanaged resources.
Remarks
, MSDN http://msdn.microsoft.com/en-us/library/aa325890(v=vs.71).aspx, OleDbConnection.Dispose() OleDbConnection.Close().
OleDbConnection.Dispose()
OleDbConnection.Close()
, MSDN:
Dispose Close OleDbConnection .
, .NET Framework 1.1. ( ) , .
, 100% , , IDbConnection, "" Dispose - , , , Close .
IDbConnection
Dispose
Close
, , .
Yes. If this is not so, then he cannot completely dispose of the resources. BinaryReader, BinaryWriter, etc. Everything also closes the underlying stream
Here is the final proof .. the actual method code Disposetaken using the reflector:
// System.Data.OleDb.OleDbConnection protected override void Dispose(bool disposing) { if (disposing) { this._userConnectionOptions = null; this._poolGroup = null; this.Close(); } this.DisposeMe(disposing); base.Dispose(disposing); }