DBErrorCode – PB Docs 150

DBErrorCode method (DataWindows)

Description

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

note.png Obsolete method

DBErrorCode is obsolete and will be discontinued
in the future. You should replace all use of DBErrorCode as
soon as possible. The database error code is available as an argument
in the DBError event.

Controls

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object

Syntax

[PowerBuilder]

Argument

Description

dwcontrol

A reference to a DataWindow control or
child DataWindow

Return Values

Returns an error code when a database error occurs in dwcontrol.
Error codes –1 through –4 are PowerBuilder codes.
Other codes are database-specific. Returns 0 if there is no error.

If dwcontrol is null, the method returns
null.

PowerBuilder error codes are:

  • –1 Can’t
    connect to the database because of missing values in the transaction
    object.

  • –2 Can’t connect to the database.

  • –3 The key specified in an Update or Retrieve
    no longer matches an existing row. (This can happen when another
    user has changed the row after you retrieved it.)

  • –4 Writing a blob to the database failed.

Usage

When a database error occurs while a DataWindow control is
interacting with the database, PowerBuilder triggers the DBError
event. Since DBErrorCode 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 code for dw_employee:

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

These statements check the error code for dw_employee
and if it is -4, perform some processing:

When an error occurs in dw_Emp, the following
statements in the DBError event’s script will display the
error number and message. A return code of 1 suppresses the default
error message:

See Also


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x