|
<< Click to Display Table of Contents >> Using DbiGetErrorInfo to get immediate information |
![]() ![]()
|
DbiGetErrorInfo provides immediate descriptive error information about the last error that occurred. This information consists of the DBIResult error code, an error message in ANSI characters corresponding to the code, and up to four associated error contexts. For example, if the error message is "Table Not Found," the user might want to know the table name. The BDE engine logged the table name with the error context ecTABLENAME, which can be found in one of the contexts contained in the DBIErrInfo structure.
The application calls DbiGetErrorInfo which returns relevant error information in the provided DBIErrInfo structure. These structure types are shown in the following table.
DbiErrorInfo Structure
Type |
Name |
Description |
DBIResult |
iError |
Last error code returned |
DBIMSG |
szErrCode |
More descriptive information |
DBIMSG |
szContext1 |
Context 1 |
DBIMSG |
szContext2 |
Context 2 |
DBIMSG |
szContext3 |
Context 3 |
DBIMSG |
szContext4 |
Context 4 |
This function immediately displays up to four error contexts to the user, while the function DbiGetErrorContext returns only the specific error context requested by the user.
If all that is required is a formatted error message for the end user, DbiGetErrorInfo is a more convenient way to get it.
These examples shows how to get information about an error when a BDE function returns a value other than DBIERR_NONE:
hDBIDb hDb;
DBIResult rslt;
DBIMSG dbiStatus;
// Open a STANDARD database
rslt = DbiOpenDatabase(NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
NULL, 0, NULL, NULL, &hDb);
if (rslt != DBIERR_NONE)
{
// An error occurred. Retrieve the error string.
DbiGetErrorString(rslt, dbiStatus);
}