OledbConnection.Dispose () close the connection?

Possible duplicate:
Do I need to close DbConnection if the use clause is used?

Does the OledbConnection.Dispose()connection close ?

I know what I'm SqlConnectiondoing, but what about OledbConnection?

+5
source share
5 answers

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.

+3
source

, MSDN http://msdn.microsoft.com/en-us/library/aa325890(v=vs.71).aspx, OleDbConnection.Dispose() OleDbConnection.Close().

+2

, MSDN:

Dispose Close OleDbConnection .

, .NET Framework 1.1. ( ) , .

, 100% , , IDbConnection, "" Dispose - , , , Close .

, , .

+1

Yes. If this is not so, then he cannot completely dispose of the resources. BinaryReader, BinaryWriter, etc. Everything also closes the underlying stream

0
source

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);
}
0
source

All Articles