Gets the current state of the connection.
[Visual Basic]
Public ReadOnly Property State As ConnectionState Implements _
IDbConnection.State
[C#]
public ConnectionState State {get;}
[C++]
public: __property ConnectionState get_State();
[JScript]
public function get State() : ConnectionState;
A bitwise combination of the System.Data.ConnectionState values. The default is Closed.
[Visual Basic, C#] The following example creates an instance of a derived class, DB2Connection , sets its ConnectionString, and displays its State.
[Visual Basic]
Public Sub createDB2Connection()
Dim myConnection As New DB2Connection()
myConnection.ConnectionString = _
"DATABASE=SAMPLE;"
myConnection.Open()
MessageBox.Show("Connection State: " + myConnection.State.ToString())
myConnection.Close()
End Sub
[C#]
public void createDB2Connection()
{
DB2Connection myConnection = new DB2Connection();
myConnection.ConnectionString = "DATABASE=SAMPLE;";
myConnection.Open();
MessageBox.Show("Connection State: " + myConnection.State.ToString());
myConnection.Close();
}