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 。