Главная страница | назад

Article #21553: Getting "unmapped SQL error code 10038" when connecting to MS SQL.


Why am I getting the error "Unmapped SQL error code 10038 - Attempt to initiate new SQL server operation with results pending"?


One reason we have found for this error is an incomplete connection to the server via a VPN and/or proxy server. We have Debugged the BDE code up to the point of a dialup connection to a server failing with the 10038 error. It failed during the single MS DBLIB function call to connect to the server. There aren't any changes that can be made or options that can be set that will "fix" this. It seems to do with how a MS DBLIB connection behaves across a firewall and/or VPN. Each subsequent action against the server (executing an sql statement of any kind) resulted in the "...results pending error".

You might find that other tools don't do this. MS's Windows ISQL is a good example. The main difference there is that it will try to reconnect when the initial connection appears to been dropped or failed to succeed. The BDE does not do this because many of its operations rely on a persistent connection to carry out supported features."

There is now a way to work around this. There is a new TDatabase param called "CANCEL QUERY". It can be set to either "dbcancel" or "dbcanquery". In addition to params like:

USER NAME=varick

a TDatabase's params list can include

CANCEL QUERY=dbcanquery

"dbcancel" is the default. "dbcanquery" was added to take care of those situations where the MSSQL server is unable to process a "dbcancel" of pending results which may be the case when getting this error.

But before this property can be used in a TDatabase the parameter must be added for the MSSQL driver. This can be done by adding the following registry entry to the DB OPEN section of the MSSQL driver (using REGEDIT.EXE):


Name: CANCEL QUERY Data: ""

Without the registry change the CANCEL QUERY param in the TDatabase has no affect (always dbcancel). Once the registry entry had been made to the MSSQL driver the CANCEL QUERY param could be used to control the cancel mode (dbcancel or dbcanquery).

Another possible workaround might be to use ODBC instead as it does not use DBLIB.

Last Modified: 11-OCT-00