PRB: Checking Version of Driver Manager from an Application

ID: Q115881


The information in this article applies to:


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 because 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, a self-extracting file, on the following services:



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

For additional information about downloading, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services

Additional query words: 1.50 C++ Excel Word Desktop Database DM Access VB Basic MSVC


Keywords          : kbfile 
Version           : WINDOWS:1.5,2.0
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: July 9, 1999