Export (0) Print
Expand All

OracleConnection.State Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets the current state of the connection.

[Visual Basic]
Public Overridable ReadOnly Property State As ConnectionState  _
   Implements IDbConnection.State
[C#]
public virtual ConnectionState State {get;}
[C++]
public: __property virtual ConnectionState get_State();
[JScript]
public function get State() : ConnectionState;

Property Value

A bitwise combination of the System.Data.ConnectionState values. The default is Closed.

Implements

IDbConnection.State

Remarks

The allowed state changes are:

  • From Closed to Open, using the Open method of the OracleConnection object.
  • From Open to Closed, using either the Close method or the Dispose method of the OracleConnection object.

Example

[Visual Basic, C#, C++] The following example creates an instance of a derived class, OracleConnection, sets its ConnectionString, and displays its State.

[Visual Basic] 
Public Sub createOracleConnection()
    Dim myConnection As New OracleConnection()
    myConnection.ConnectionString = _
       "Data Source=Oracle8i;Integrated Security=yes"
    myConnection.Open()
    MessageBox.Show("Connection State: " + myConnection.State)
    myConnection.Close()
End Sub

[C#] 
public void createOracleConnection()
{
   OracleConnection myConnection = new OracleConnection();
   myConnection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
   myConnection.Open();
   MessageBox.Show("Connection State: " + myConnection.State);
   myConnection.Close();
}

[C++] 
public:
 void createOracleConnection()
 {
    OracleConnection* myConnection = new OracleConnection();
    myConnection->ConnectionString = S"Data Source=Oracle8i;Integrated Security=yes";
    myConnection->Open();
    MessageBox::Show(String::Format( S"Connection State: {0}", __box(myConnection->State)));
    myConnection->Close();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleConnection Class | OracleConnection Members | System.Data.OracleClient Namespace

Show:
© 2014 Microsoft