GetError

Description

Returns the first error object.

Applies to

PSConnectionClass objects

Syntax

connectionobject.GetError( )

Argument

Description

connectionobject

A variable that contains a reference to an instance of PSConnectionClass

Returns

PSErrorClass object. If multiple errors were generated by the last database operation, GetError returns the first error object. If there were no errors, it returns null.

Usage

At runtime, GetError returns an error object that stores database connection errors.

Examples

Example 1

In this example, “myconnect” is a variable of type PSConnectionClass, “mycommand” is a variable of type PSCommandClass, “mycursor” is a variable of type PSCursorClass, “myquery” is a variable of type String, “dberror” is a variable of type boolean, and “errobj” is a variable of type PSErrorClass. After each database operation, a GetError call checks for errors. If an error occurs, the error code and message are displayed:

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 );
 			}