IDbConnection.State Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
One of the ConnectionState values.
Examples
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
Remarks
The allowed state changes are:
From
Closed
toOpen
, using theOpen
method of the Connection object.From
Open
toClosed
, using either theClose
method or theDispose
method of the Connection object.
Applies to
שתף איתנו פעולה ב- GitHub
ניתן למצוא את המקור לתוכן זה ב- GitHub, שם ניתן גם ליצור ולסקור בעיות ולמשוך בקשות. לקבלת מידע נוסף, עיין במדריך התורמים שלנו.