Reports the database-specific error message that triggered the DBError event.
Obsolete method 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.
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control, DataWindowChild object |
string dwcontrol.DBErrorMessage ( )
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control or child DataWindow |
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.
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.
This statement returns the error message generated by a database error in dw_employee:
dw_employee.DBErrorMessage()
Since this method is meaningful only in a DataWindow, you can use the pronoun This instead of the DataWindow’s name:
This.DBErrorMessage()
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:
string err_msg
err_msg = This.DBErrorMessage()
IF err_msg <> "" THEN
MessageBox("DBError", "Number" + &
String(This.DBErrorCode())+ " " + &
err_msg, StopSign!)
// Stop PowerBuilder from displaying the error
RETURN 1
END IF