Microsoft KB Archive/115881

{|
 * width="100%"|

PRB: Checking Version of Driver Manager from an Application

 * }

Q115881

-

The information in this article applies to:


 * Microsoft Open Database Connectivity, versions 1.5, 2.0

-

SUMMARY
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 preceding 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. 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:

 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.  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 }  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
The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

"Getver.exe" For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

"Q119591 How to Obtain Microsoft Support Files from Online Services" Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

Sample File 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).

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

Keywords : kbfile kbODBC kbGrpVCDB kbDSupport

Issue type : kbprb kbinfo

Technology :