System.Data.Odbc.OdbcConnection.Close Method

Closes the connection to the data source.

Syntax

public override void Close ()

Remarks

The OdbcConnection.Close method rolls back any pending transactions. It then releases the connection to the connection pool, or closes the connection if connection pooling is disabled. If OdbcConnection.Close is called while handling a System.Data.Common.DbConnection.StateChange event, no additional System.Data.Common.DbConnection.StateChange events are fired.

An application can call OdbcConnection.Close more than one time without generating an exception.

Note:

When you use the .NET Framework Data Provider for ODBC, you do not have to enable connection pooling because the ODBC Driver Manager manages this automatically. For more information about how to enable and disabling connection pooling, see the Microsoft Open Database Connectivity (ODBC) documentation.

Note:

Do not call OdbcConnection.Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Garbage Collection.

Requirements

Namespace: System.Data.Odbc
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0