PRB: Checking Version of Driver Manager from an Application

Last reviewed: October 14, 1997
Article ID: Q115881
1.50 WINDOWS kbusage kbfile

The information in this article applies to:

  - Microsoft Open Database Connectivity, version 1.5
  - Microsoft Open Database Connectivity, version 2.0

SYMPTOMS

An ODBC version 2.0 application needs to have a version 2.0 ODBC driver manager (ODBC.DLL). One way to verify the version of the driver manager is to make a call to SQLGetInfo with fInfoType= SQL_ODBC_VER. An application must connect to a specific driver before calling SQLGetInfo as that function requires a valid connected hdbc (connection handle).

Note, for certain post-1.0 and pre-2.0 versions of ODBC.DLL (actual file version 1.5.xxxx), the return value for the SQLGetInfo call with InfoType=SQL_ODBC_VER, is "02.00.0000" or "02.00".

For example, the driver manager ODBC.DLL that shipped with Microsoft Word version 6.0 for Windows returns "02.00" for the above call. Similarly, the driver manager ODBC.DLL that shipped with Microsoft Visual C version 1.5 for Windows, returns the version as "02.00.0000". Therefore, a 2.0 ODBC application which uses SQLGetInfo to confirm it is using a true 2.0 driver manager may fail against one of these earlier versions.

WORKAROUND

In order to correctly distinguish a true 2.0 driver manager from one returning an incorrect version (referenced above), a version 2.0 application should incorporate one of the following checks to ensure that an incorrect version of driver manager is not loaded:

  1. An easy way for an application to make sure the driver manager is at least the released version 2.0 is to call SQLGetFunctions(hdbc,72) to see if SQLBindParameter is available. Only the "real" 2.0 driver manager will return "TRUE" in this case. However, this workaround (like calling SQLGetInfo) requires a connected hdbc. This causes an application to lead the user through the steps of connecting and then potentially inform the user that they have an incompatible version. This is applicable to both SQLGetInfo and SQLGetFunctions calls in general.

  2. A better option for an application is to use the following information to detect the 2.0 or later driver manager. Driver version 1.5 and later have a string character that specifies the cursor level. It is used by driver manager and the cursor library to make sure that they will work together. The final 2.0 release has a cursor level of "g". Therefore, any letter greater than or equal to "g" is a 2.0 or later driver manager. This string can be obtained by loading string id# 199 from the ODBC.DLL module. The following code example demonstrates how to get this information.

          char buf[2];
          HMODULE hmodule;
    

          hmodule = GetModuleHandle ("odbc.dll");
          if (LoadString (hmodule, 199, buf, sizeof(buf)))
          {
    
             if ((*buf | 0x20) >= 'g')
             {
                         //        Release 2.0 DM or later
             }
             else
             {
                        //         Older Driver Manager
             }
          }
          else
          {
             //         Older Driver Manager
          }
    
    

  3. A third option for an application is to directly check the version information in the ODBC.DLL prior to making use of any ODBC functionality. This can be done using Windows Version Functions.

    For a sample program that checks the file version using Windows Version Functions, please check the Microsoft Software Library (MSL).

MORE INFORMATION

GETVER.EXE is a sample program that uses the version functions in Microsoft Windows version 3.1 Software Development Kit (SDK) to get the file version of ODBC driver manager (ODBC.DLL).

You can find GETVER.EXE (size: 90348 bytes) 
                       , a self-extracting file, on the following services:

  • Microsoft's World Wide Web Site on the Internet

          On the www.microsoft.com home page, click the Support icon.
          Click Knowledge Base, and select the product area.
    
          Enter kbfile GETVER.EXE (size: 90348 bytes) 
                                 , and click GO!
          Open the article, and click the button to download the file.
    
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the Softlib/Mslfiles folder.
          Get GETVER.EXE (size: 90348 bytes) 
    
  • The Microsoft Network

          On the Edit menu, click Go To, and then click Other Location.
          Type "mssupport" (without the quotation marks).
          Double-click the MS Software Library icon.
          Find the appropriate product area.
          Locate and Download GETVER.EXE.
    
  • Microsoft Download Service (MSDL)

          Dial (425) 936-6735 to connect to MSDL
          Download GETVER.EXE (size: 90348 bytes) 
    

    For additional information about downloading, please see the following article in the Microsoft Knowledge Base:

       ARTICLE-ID: Q119591
       TITLE     : How to Obtain Microsoft Support Files from Online
                   Services
    

  • Additional reference words: 1.50 2.00 C++ Excel Word Desktop Database DM
    Access VB Basic MSVC
    KBCategory: kbusage kbfile
    KBSubcategory:
    Keywords : kbfile kbusage
    Version : 1.50
    Platform : WINDOWS


    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: October 14, 1997
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.