Returns the code associated with the current error object.
PSErrorClass objects
errorobject.GetCode( )
Argument |
Description |
---|---|
errorobject |
A variable that contains a reference to an instance of PSErrorClass |
String. Returns the error code.
At runtime, GetCode returns the error code stored in an error object.
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 );
}