GetCode

Description

Returns the code associated with the current error object.

Applies to

PSErrorClass objects

Syntax

errorobject.GetCode( )

Argument

Description

errorobject

A variable that contains a reference to an instance of PSErrorClass

Returns

String. Returns the error code.

Usage

At runtime, GetCode returns the error code stored in an error object.

Examples

Example 1

The following example connects to a database and retrieves some data. In this example, “mycommand” is a variable of type PSCommandClass, “mycursor” is a variable of type PSCursorClass, “myquery” is a variable of type String, and “dberror” is a variable of type boolean. If an error occurs, a GetCode call retrieves the code for the error:

myconnect =
		psServer.GetConnection("SalesDBConnection");
if ( myconnect.GetError() == null )
		{
		myquery = "Select * from sales"; 
		mycursor = myconnect.CreateCursor ( myquery );
		if ( myconnect.GetError() == null )
			{
			// Process the retrieved data
			}
 		else dberror = true;
		}
else dberror = true;
		if ( dberror == true )
			{
			errobj = myconnect.GetError();
			str = errobj.GetCode() + " " +
				errobj.GetMessage();
			psDocument.Write ( str );
			}