PRB: Mouse Disappears or Machine Hangs When Connecting to ODBC

Last reviewed: August 4, 1997
Article ID: Q171859
The information in this article applies to:
  • Microsoft Visual Basic Professional and Enterprise Editions, 16-bit only, for Windows, version 4.0

SYMPTOMS

When trying to connect to an ODBC datasource from a datacontrol or the Data Access Objects (DAO), the mouse disappears, the machine hangs, or the machine General Protection Faults (GPF).

Attempting to connect to an ODBC datasource from Visual Basic 4.0 16-bit, causes the machine to behave as described above. It only occurs when a driver attempts to display a sign-on banner or a login dialog. For most drivers, a dialog is not displayed if a full connect string is provided, avoiding the problem.

CAUSE

The problem is due to the driver not correctly handling the window handle (HWND) that is passed to it on the SQLDriverConnect ODBC API call. The HWND parameter of this ODBC function call is defined in the ODBC 2.0 Programmer's Reference and SDK Guide as:

"Input. Window handle. The application can pass the handle of the parent window, if applicable, or a null pointer if either the window handle is not applicable or if SQLDriverConnect will not present any dialog boxes."

Because many ODBC driver vendors implemented their drivers such that a NULL HWND would never show dialogs, Visual Basic was forced to pass in a valid window handle. Because there is not always a window associated with a Visual Basic application, Visual Basic passes in the Desktop window handle. This causes a problem for many drivers. Many drivers simply take the HWND parameter passed in and use it in the calls to show their dialogs. The problem is that the dialog functions are documented such that NULL should be used when the Desktop window is to be used as the parent. Passing the Desktop window as the parent in the dialog calls can and does have adverse effects that are causing the problems listed above.

RESOLUTION

Upgrade to version 2.10.2401 of the ODBC Driver Manager (ships with Visual Basic 4.0 Professional and Enterprise) and have the ODBC driver vendor modify the driver such that it checks for the Desktop window and uses NULL for the parent window in the calls to the dialog functions. The SQL Server driver versions 2.10.2401 and greater does this correctly. The logic in the driver should be something like:

   RETCODE SQLDriverConnect(HDBC hdbc, HWND hwnd, UCHAR FAR * szConnStrIn,
SWORD cbConnStrIn, UCHAR FAR * szConnStrOut, SWORD cbConnStrOutMax, SWORD FAR * pcbConnStrOut, UWORD fDriverCompletion)
   {
     //...... otherlogic
   if (GetDeskTopWindow() == hwnd){hwnd = NULL;}
    //rest of logic (to show dialogs)
   }

STATUS

This is an ODBC driver implementation problem. Contact the driver vendor for an updated driver. If the driver vendor does not have an updated driver, provide them with the information in the RESOLUTION section of this article.

NOTE: This problem does affect early ODBC Driver Manager (ODBC.DLL) and SQL Server driver versions. The problem was fixed in the 2.10.2401 versions of these components.

REFERENCES

(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Troy Cambra, Microsoft Corporation

Keywords          : vb416 VB4WIN kb3rdparty kbenv
Version           : 4.0
Platform          : WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 4, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.