DBError event
Description
Occurs when a database error occurs in the DataWindow or DataStore.
PowerBuilder event information
Event ID: pbm_dwndberror
Argument |
Description |
---|---|
sqldbcode |
Long by value. A database-specific error See your DBMS documentation for information on the meaning When there is no error code from the DBMS, sqldbcode contains
|
sqlerrtext |
String by value. A database-specific |
sqlsyntax |
String by value. The full text of the SQL statement being sent to the DBMS |
buffer |
DWBuffer by value. The buffer containing For a list of valid values, see DWBuffer. |
row |
Long by value. The number of the row involved in the database activity that |
Web ActiveX event information
Event name: onDBError
Argument |
Description |
---|---|
SQLDatabaseCode |
Number. A database-specific error code. See your DBMS documentation for information on the meaning When there is no error code from the DBMS, SQLDatabaseCode contains
|
SQLDatabaseErrorText |
String. A database-specific error message. |
SQLSyntax |
String. The full text of the SQL statement being sent to the DBMS |
dwBuffer |
Number. The buffer containing the row For a list of valid values, see DWBuffer. |
row |
Number. The number of the row involved |
Return Values
Set the return code to affect the outcome of the event:
-
0
Display the error message and trigger the Transaction object’s
DBError event if it is defined. -
1
Do not display the error message, and trigger the Transaction
object’s DBError event if it is defined. -
2
Display the error message and ignore the Transaction object’s
DBError event whether it is defined or not. -
3
Do not display the error message and ignore the Transaction
object’s DBError event whether it is defined or not.
For information on setting the return code in a particular
environment, see “About return values for
DataWindow events”.
Usage
By default, when the DBError event occurs in a DataWindow
control, it displays a system error message. You can display your
own message and suppress the system message by specifying a return
code of 1 in the DBError event.
Since DataStores are nonvisual, a system message does not
display when the DBError event occurs in a DataStore. You must add
code to the DBError event to handle the error.
If the row that caused the error is in the Filter buffer,
you must unfilter it if you want the user to correct the problem.
The row number stored in row is the number
of the row in the buffer, not the number the row had when it was
retrieved into the DataWindow object.
Obsolete methods in PowerBuilder
Information formerly provided by the DBErrorCode and DBErrorMessage methods
is available in the arguments sqldbcode and sqlerrtext.
Examples
This example illustrates how to display custom error
messages for particular database error codes:
1 |
CHOOSE CASE sqldbcode |
1 |
1 |
CASE -195 // Required value is NULL. |
1 |
MessageBox("Database Problem", & |
1 |
"Error inserting row " + string(row) & |
1 |
+ ". Please specify a value for Employee ID.") |
1 |
CASE ... |
1 |
// Code to handle other errors |
1 |
1 |
END CHOOSE |
1 |
1 |
RETURN 1 // Do not display system error message |