OracleConnection.State 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得連線目前的狀態。
public:
property System::Data::ConnectionState State { System::Data::ConnectionState get(); };
public:
virtual property System::Data::ConnectionState State { System::Data::ConnectionState get(); };
[System.ComponentModel.Browsable(false)]
public System.Data.ConnectionState State { get; }
[System.ComponentModel.Browsable(false)]
public override System.Data.ConnectionState State { get; }
[<System.ComponentModel.Browsable(false)>]
member this.State : System.Data.ConnectionState
Public ReadOnly Property State As ConnectionState
Public Overrides ReadOnly Property State As ConnectionState
屬性值
ConnectionState 值的位元組合。 預設為 Closed
。
實作
- 屬性
範例
下列範例會建立衍生類別的實例、 OracleConnection設定其 ConnectionString,並顯示其 State。
public void createOracleConnection()
{
using (OracleConnection connection = new OracleConnection())
{
connection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
connection.Open();
Console.WriteLine("Connection State: " + connection.State);
}
}
Public Sub createOracleConnection()
Using connection As New OracleConnection()
connection.ConnectionString = _
"Data Source=Oracle8i;Integrated Security=yes"
connection.Open()
Console.WriteLine("Connection State: " & connection.State)
End Using
End Sub
備註
允許的狀態變更如下:
從
Closed
到Open
,使用Open
物件的 方法 OracleConnection 。從
Open
到Closed
,使用 Close 物件的 方法 OracleConnection 。