DBErrorMessage

Description

Reports the database-specific error message that triggered the DBError event.

NoteObsolete 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.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object

Syntax

PowerBuilder

string dwcontrol.DBErrorMessage ( ) 

Argument

Description

dwcontrol

A reference to a DataWindow control or child DataWindow

Returns

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

Example 1

This statement returns the error message generated by a database error in dw_employee:

dw_employee.DBErrorMessage()

Example 2

Since this method is meaningful only in a DataWindow, you can use the pronoun This instead of the DataWindow’s name:

This.DBErrorMessage()

Example 3

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

See also