DBX Error Handling

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Posts: 1
Joined: Tue 09 Oct 2018 06:28

DBX Error Handling

Post by asubhani344 » Tue 09 Oct 2018 14:34


IDE delphi 2009 Database: SQL Server

Our application is a multi-threaded application, in past we were using dbxmss driver for database connectivity and it works fine for TLS protocol 1.0 and 1.1 but it doesn't support TLS protocol 1.2.

For this problem we got the Devart DBExpress driver version 7.4.6, compiled the dbexpsda40 dll and set the required parameters as below: it works fine for TLS protocol 1.2 and also for earlier versions 1.0. 1.1 which is good

dbexpsda40.dll (compiled )

Driver Name : DevartSQLServer
Driver Function : getSQLDriverSQLServer
Library Name : dbexpsda40.dll
Vendor Library : sqlncli11

However, In our application we check the database connection sanity by executing a simple SQL query after defined interval (15/30 seconds) if application gets disconnected due to any reason (network problem, SQL service stop etc.. )application goes into retry mechanism. Before Devaert retry mechanism was triggering on specific TDBXError error codes 16389 (network error ) or 101 (connection error)

While doing Devart DBExpress driver development testing we have found that in case of failure in most scenarios DBXErrorCode:65535 is returned.

1) If SQL service is stopped and start the application connection failed DBXErrorCode:65535
2) If SQL server is on remote machine and network has disconnected start the application connection failed DBXErrorCode:65535
3) In valid SQL due to any reason colunm name or table name is incorrect or missing DBXErrorCode:65535
4) Database name is missing or incorrect DBXErrorCode:65535


1) DBXErrorCode:65535 is same for all different types of failure? i have noticed only in case of authentication failure DBXErrorCode: 12 is returned.
2) how we can differentiate is it connection failure (network issue / SQL service is not responding )or Invalid SQL failure?
3) I can see TDBXError has TDBXErrorCodes constant class but TDBXError exception error code always come up with 65535

NoMemory = $0002;
UnsupportedFieldType = $0003;
ConnectionFailed = $0015;


Devart Team
Posts: 215
Joined: Tue 03 Oct 2017 11:00

Re: DBX Error Handling

Post by Stellar » Tue 05 Feb 2019 15:39

Unfortunately, this is a limitation of dbExpress technology. The value of the TDBXError.ErrorCode property is the function call result, but not the server error code.
The function call result in DBX is of Word type. DBX creates the final exception object and the error code is the function execution result.
We cannot use the error code of SQL Server, because it is of Integer type, and the function call result in DBX is of Word type.
If getting error codes is critical for you, then you can use UniDAC or SDAC, where there are no such limitations.

Post Reply