OleDbConnection.Close 方法


关闭到数据源的连接。Closes the connection to the data source.

 virtual void Close();
public void Close ();
override this.Close : unit -> unit
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. 如果在处理 StateChange 事件时调用 Close,则不会触发其他 StateChange 事件。If Close is called while handling a StateChange event, no additional StateChange events are fired.

应用程序可以多次调用 CloseAn application can call Close more than one time. 不生成异常。No exception is generated.


不要对 OleDbConnectionOleDbDataReader或类的 Finalize 方法中的任何其他托管对象调用 CloseDisposeDo 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.