Skip Headers
Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 2 (10.2)

Part Number B14308-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

ErrorNumber Method

Applies To

OAdvise, OBinder, OClient, OConnection, OConnectionCollection, ODatabase, ODatabaseCollection, ODynaset, ODynasetMark, OField, OFieldCollection, OParameter, OParameterCollection, OSession, OSessionCollection

Description

This method returns an internal class library error number.

Usage

long ErrorNumber(void) const

Remarks

This method reports class library error numbers. If there is no error the result will be OERROR_NONE. Otherwise the result will be one of the other OERROR error codes defined in the ORACL.H header file. These error numbers are discussed in the Error Handling section. Depending on the error, there may be more information available using the GetErrorText function.

Oracle database errors (as distinct from error that occur in the use of the class library) are reported through the OSession and ODatabase methods ServerErrorNumber and GetServerErrorText.

Return Value

The internal class library error number.

Example

This example shows two different kinds of errors and how they are reported

// construct but do not open an ODatabase

OSession sess(0); // get default session

ODatabase odb; // construct an unopened ODatabase

// now try to open a dynaset with that

ODynaset empdyn(odb, "select * from emp");

// that failed, so the dynaset is not open

if (!empdyn.IsOpen())

{ // we'll always get here

long errno = empdyn.ErrorNumber();

// errno will be OERROR_INVPARENT

// because the database was closed

}

// now let's open the database incorrectly

oresult ores = odb.Open(sess, "ExampleDB", "scott", "nottiger");

// the database isn't open because of the bad password

if (ores != OSUCCESS)

{ // we'll always get here

long errno = sess.ServerErrorNumber();

// errno will be 1017: invalid username/password

}