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 has the following behavior:

Application server

Runtime behavior

ASP

Returns the error code, which was obtained by accessing the Number property of the Error object

JSP

Returns the error code stored in an error object

Examples

Example 1

The following example connects to a database and retrieves some data. If an error occurs, it uses GetCode to retrieve 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 );
			}

To use the same example in a JSP target, you must declare “mycommand” as a variable of type PSCommandClass before instantiating it and calling any methods on it. You must also declare “mycursor” as a variable of type PSCursorClass, “myquery” as a variable of type String, and “dberror” as a variable of type boolean.