OracleConnection.Close 方法
定义
关闭与数据库之间的连接。Closes the connection to the database.
public:
override void Close();
public override void Close ();
override this.Close : unit -> unit
Public Overrides Sub Close ()
注解
Close 方法将回滚所有挂起的事务。The 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.
应用程序可以多次调用 Close,而不会生成异常。An application can call Close more than once without generating an exception.
备注
使用适用于 Oracle 的 .NET Framework 数据提供程序时,无需启用连接池,因为提供程序会自动管理此。When you use the .NET Framework Data Provider for Oracle, you do not need to enable connection pooling because the provider manages this automatically.
注意
不要对 OracleConnection、OracleDataReader或类的 Finalize
方法中的任何其他托管对象调用 Close。Do not call Close on a OracleConnection, a OracleDataReader, 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. 如果类不拥有任何非托管资源,则不要在类定义中包含 Finalize
方法。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.