Skip Headers

Oracle Data Provider for .NET Developer's Guide
Release 9.2.0.2

Part Number A96160-01
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to beginning of chapter Go to next page

Oracle.DataAccess.Client Namespace, 9 of 26


OracleException Class

The OracleException class represents an exception that is thrown when the Oracle Data Provider for .NET encounters an error. Each OracleException object contains at least one OracleError object in the Error property that describes the error or warning.

Class Inheritance

Object

  Exception

    SystemException

      OracleException

Declaration
// C#
public sealed class OracleException : SystemException
Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Example
// C#
//  The following example generates an OracleException due to bad SQL syntax,
//  (that is the missing keyword "from") and then displays the exception message 
//  and source property.
..
try
{
  ...
  // select * emp will cause ORA-00923
  OracleCommand cmd = new OracleCommand("select * emp", con);
}
catch ( OracleException e )
{
  Console.WriteLine("{0} throws {1}",e.Source, e.Message);
}
..

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccesss.dll

See Also:

OracleException Members

OracleException members are listed in the following tables:

OracleException Static Methods

OracleException static methods are listed in Table 4-63.

Table 4-63 OracleException Static Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

OracleException Properties

OracleException properties are listed in Table 4-64.

Table 4-64 OracleException Properties  
Properties Description

DataSource

Specifies the TNS name that contains the information for connecting to an Oracle instance

Errors

Specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database

HelpLink

Inherited from Exception

InnerException

Inherited from Exception

Message

Specifies the error messages that occur in the exception

Number

Specifies the Oracle error number

Procedure

Specifies the stored procedure that cause the exception

Source

Specifies the name of the data provider that generates the error

StackTrace

Inherited from Exception

TargetSite

Inherited from Exception

OracleException Methods

OracleException methods are listed in Table 4-65.

Table 4-65 OracleException Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

GetBaseException

Inherited from Exception

GetHashCode

Inherited from Object

GetObjectData

Sets the serializable info object with information about the exception

GetType

Inherited from Object

ToString

Returns the fully qualified name of this exception

See Also:

OracleException Static Methods

OracleException static methods are listed in Table 4-66.

Table 4-66 OracleException Static Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

See Also:

OracleException Properties

OracleException properties are listed in Table 4-67.

Table 4-67 OracleException Properties  
Properties Description

DataSource

Specifies the TNS name that contains the information for connecting to an Oracle instance

Errors

Specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database

HelpLink

Inherited from Exception

InnerException

Inherited from Exception

Message

Specifies the error messages that occur in the exception

Number

Specifies the Oracle error number

Procedure

Specifies the stored procedure that cause the exception

Source

Specifies the name of the data provider that generates the error

StackTrace

Inherited from Exception

TargetSite

Inherited from Exception

See Also:

DataSource

This property specifies the TNS name that contains the information for connecting to an Oracle instance.

Declaration
// C#
public string DataSource {get;}
Property Value

The TNS name containing the connect information.

See Also:

Errors

This property specifies a collection of one or more OracleError objects that contain information about exceptions generated by the Oracle database.

Declaration
// C#
public OracleErrorCollection Errors {get;}
Property Value

An OracleErrorCollection.

Remarks

The Errors property contains at least one instance of OracleError objects.

See Also:

Message

Overrides Exception

This property specifies the error messages that occur in the exception.

Declaration
// C#
public override string Message {get;}
Property Value

A string.

Remarks

Message is a concatenation of all errors in the Errors collection. Each error message is concatenated and is followed by a carriage return, except the last one.

See Also:

Number

This property specifies the Oracle error number.

Declaration
// C#
public int Number {get;}
Property Value

The error number.

Remarks

This error number can be the topmost level of error generated by Oracle and can be a provider-specific error number.

See Also:

Procedure

This property specifies the stored procedure that caused the exception.

Declaration
// C#
public string Procedure {get;}
Property Value

The stored procedure name.

Remarks

See Also:

Source

Overrides Exception

This property specifies the name of the data provider that generates the error.

Declaration
// C#
public override string Source {get;}
Property Value

The name of the data provider.

See Also:

OracleException Methods

OracleException methods are listed in Table 4-68.

Table 4-68 OracleException Methods  
Methods Description

Equals

Inherited from Object (Overloaded)

GetBaseException

Inherited from Exception

GetHashCode

Inherited from Object

GetObjectData

Sets the serializable info object with information about the exception

GetType

Inherited from Object

ToString

Returns the fully qualified name of this exception

See Also:

GetObjectData

Overrides Exception

This method sets the serializable info object with information about the exception.

Declaration
// C#
public override void GetObjectData(SerializationInfo info, StreamingContext 
context);
Parameters
Remarks

The information includes DataSource, Message, Number, Procedure, Source, and StackTrace.

See Also:

ToString

Overrides Exception

This method returns the fully qualified name of this exception, the error message in the Message property, the InnerException.ToString() message, and the stack trace.

Declaration
// C#
public override string ToString();
Return Value

The string representation of the exception.

Example
// C#
...
try
{
  ...
  // select * from emp will cause ORA-00923
  OracleCommand cmd = new OracleCommand("select * from emp", con);
}
catch ( OracleException e )
{
  Console.WriteLine("{0}",e.ToString());
}
...

See Also:


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2002 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents
Go To Index
Index