Returns the first error object.
PSConnectionClass objects
connectionobject.GetError( )
Argument |
Description |
---|---|
connectionobject |
A variable that contains a reference to an instance of PSConnectionClass |
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.
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 |
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 );
}