OleDbConnection.Close OleDbConnection.Close OleDbConnection.Close OleDbConnection.Close Method

定义

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

public:
 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. 如果CloseStateChange处理事件时调用,则不会触发任何其他事件。 StateChangeIf 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 FinalizeOleDbDataReader或类的方法中的任何其他托管对象调用或释放。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.

适用于

另请参阅