Export (0) Print
Expand All

OracleException Class

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

The exception that is generated when a warning or error is returned by an Oracle database or the .NET Framework Data Provider for Oracle. This class cannot be inherited.

For a list of all members of this type, see OracleException Members.

System.Object
   System.Exception
      System.SystemException
         System.Data.OracleClient.OracleException

[Visual Basic]
<Serializable>
NotInheritable Public Class OracleException
   Inherits SystemException
[C#]
[Serializable]
public sealed class OracleException : SystemException
[C++]
[Serializable]
public __gc __sealed class OracleException : public
   SystemException
[JScript]
public
   Serializable
class OracleException extends SystemException

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

This class is created whenever the OracleDataAdapter encounters a situation that it cannot handle.

If the severity of the error is too great, the server may close the OracleConnection. However, the user can reopen the connection and continue.

Example

[Visual Basic, C#, C++] The following example generates an OracleException due to a missing database, and then displays the exception.

[Visual Basic] 
Public Sub ShowOracleException() 

   Dim myConnection As OracleConnection = _
      New OracleConnection("Data Source=Oracle8i;Integrated Security=yes")

   Try 

      myConnection.Open()

   Catch e As OracleException

     Dim errorMessage As String = "Code: " & e.Code & vbCrLf & _
                                  "Message: " & e.Message

     Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog()
     log.Source = "My Application"
     log.WriteEntry(errorMessage)
     Console.WriteLine("An exception occurred. Please contact your system administrator.")

   End Try
End Sub

[C#] 
public void ShowOracleException() 
{
   OracleConnection myConnection =
      new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");

   try 
   {
      myConnection.Open();
   }
   catch (OracleException e) 
   {
     string errorMessage = "Code: " + e.Code + "\n" +
                           "Message: " + e.Message;

     System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
     log.Source = "My Application";
     log.WriteEntry(errorMessage);
     Console.WriteLine("An exception occurred. Please contact your system administrator.");
   }
}

[C++] 
public:
 void ShowOracleException() 
 {
    OracleConnection* myConnection =
       new OracleConnection(S"Data Source=Oracle8i;Integrated Security=yes");

    try 
    {
       myConnection->Open();
    }
    catch (OracleException* e) 
    {
      String* errorMessage = String::Format( S"Code: {0}\nMessage: {1}", __box(e->Code), e->Message );

      System::Diagnostics::EventLog* log = new System::Diagnostics::EventLog();
      log->Source = S"My Application";
      log->WriteEntry(errorMessage);
      Console::WriteLine(S"An exception occurred. Please contact your system administrator.");
    }
 }

[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

Namespace: System.Data.OracleClient

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

Assembly: System.Data.Oracleclient (in System.Data.Oracleclient.dll)

See Also

OracleException Members | System.Data.OracleClient Namespace

Show:
© 2014 Microsoft