IDbConnection.State IDbConnection.State IDbConnection.State IDbConnection.State Property

Definition

Ruft den aktuellen Zustand der Verbindung ab.Gets the current state of the connection.

public:
 property System::Data::ConnectionState State { System::Data::ConnectionState get(); };
public System.Data.ConnectionState State { get; }
member this.State : System.Data.ConnectionState
Public ReadOnly Property State As ConnectionState

Eigenschaftswert

Beispiele

Im folgenden Beispiel wird eine Instanz einer abgeleiteten Klasse, OleDbConnection,, fest ConnectionStringgelegt und deren Stateangezeigt.The following example creates an instance of a derived class, OleDbConnection, sets its ConnectionString, and displays its State.

public void CreateOleDbConnection(){
   OleDbConnection connection = new OleDbConnection();
   connection.ConnectionString = 
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb";
   Console.WriteLine("Connection State: " + connection.State.ToString());
}
Public Sub CreateOleDbConnection()
    Dim connection As New OleDbConnection()
    connection.ConnectionString = _
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb"
    Console.WriteLine("Connection State: " & connection.State.ToString())
End Sub

Hinweise

Die zulässigen Zustandsänderungen lauten:The allowed state changes are:

  • Von Closed Open bis Open, mithilfe der-Methode des Connection-Objekts.From Closed to Open, using the Open method of the Connection object.

  • Von Open Close Dispose bis Closed, mithilfe der-Methode oder der-Methode des Connection-Objekts.From Open to Closed, using either the Close method or the Dispose method of the Connection object.

Gilt für: