DBErrorMessage method (DataWindows)
Description
Reports the database-specific error message that triggered
the DBError event.
DBErrorMessage is obsolete and will be
discontinued in a future release. You should replace all use of DBErrorMessage as
soon as possible. The database error message is available as an
argument in the DBError event.
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control, DataWindowChild object |
Syntax
[PowerBuilder]
1 |
string <span>dwcontrol</span><span>.</span><span>DBErrorMessage</span> ( ) |
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control or |
Return Values
Returns a string whose value is a database-specific error
message generated by a database error in dwcontrol.
Returns the empty string (“”) if there is no error.
If dwcontrol is null, the method returns
null.
Usage
When a database error occurs while a DataWindow control is
interacting with the database, PowerBuilder triggers the DBError
event. Since DBErrorMessage is meaningful only
if a database error has occurred, you should call this method only
in the DBError event.
Examples
This statement returns the error message generated
by a database error in dw_employee:
1 |
dw_employee.<span>DBErrorMessage</span>() |
Since this method is meaningful only in a DataWindow,
you can use the pronoun This instead of the
DataWindow’s name:
1 |
This.<span>DBErrorMessage</span>() |
If data processing fails in dw_Emp and these
statements are coded in the script for the DBError event, a message
box containing the error number and the message displays:
1 |
string err_msg |
1 |
1 |
err_msg = This.<span>DBErrorMessage</span>() |
1 |
1 |
IF err_msg <> "" THEN |
1 |
MessageBox("DBError", "Number" + & |
1 |
String(This.DBErrorCode())+ " " + & |
1 |
err_msg, StopSign!) |
1 |
// Stop PowerBuilder from displaying the error |
1 |
RETURN 1 |
1 |
END IF |