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

Application server

Runtime behavior

ASP

If the Count property of the Errors collection indicates that any errors were caused by the last database operation, creates a new instance of PSErrorClass and returns the object instance

JSP

Returns an error object that stores database connection errors

Examples

Example 1

The following example for an ASP target connects to a database and retrieves some data. After each database operation, it uses GetError to check for errors. If an error occurs, it displays the error code and message:

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