OracleConnection.State 属性
定义
获取连接的当前状态。Gets the current state of the connection.
public:
virtual property System::Data::ConnectionState State { System::Data::ConnectionState get(); };
[System.ComponentModel.Browsable(false)]
public override System.Data.ConnectionState State { get; }
member this.State : System.Data.ConnectionState
Public Overrides ReadOnly Property State As ConnectionState
属性值
ConnectionState 值的按位组合。A bitwise combination of the ConnectionState values. 默认值为 Closed
。The default is Closed
.
- 属性
示例
下面的示例创建派生类的实例,OracleConnection,设置其 ConnectionString,并显示其 State。The following example creates an instance of a derived class, OracleConnection, sets its ConnectionString, and displays its 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
注解
允许的状态更改为:The allowed state changes are:
从
Closed
到Open
,使用 OracleConnection 对象的Open
方法。FromClosed
toOpen
, using theOpen
method of the OracleConnection object.从
Open
到Closed
,使用 OracleConnection 对象的 Close 方法。FromOpen
toClosed
, using the Close method of the OracleConnection object.