IDbConnection.State Propiedad

Definición

Obtiene el estado actual de la conexión.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

Valor de propiedad

ConnectionState

Uno de los valores de ConnectionState.One of the ConnectionState values.

Ejemplos

En el ejemplo siguiente se crea una instancia de una clase derivada, OleDbConnection , se establece ConnectionString y se muestra su State .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

Comentarios

Los cambios de estado permitidos son:The allowed state changes are:

  • De Closed a Open , utilizando el Open método del objeto de conexión.From Closed to Open, using the Open method of the Connection object.

  • De Open a Closed , utilizando el Close método o el Dispose método del objeto de conexión.From Open to Closed, using either the Close method or the Dispose method of the Connection object.

Se aplica a