OleDbConnection.Close 方法
定义
关闭到数据源的连接。Closes the connection to the data source.
public:
override void Close();
public:
virtual void Close();
public override void Close ();
public void Close ();
override this.Close : unit -> unit
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Overrides Sub Close ()
Public 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 处理事件时调用 StateChange ,则不 StateChange 会触发任何其他事件。If Close is called while handling a StateChange event, no additional StateChange events are fired.
应用程序可以调用多次 Close 。An application can call Close more than one time. 不生成异常。No exception is generated.
注意
不要对 Close OleDbConnection 、 OleDbDataReader 或类的方法中的任何其他托管对象调用或释放 Finalize 。Do not call Close or Dispose on an OleDbConnection, an OleDbDataReader, 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.