ODBC Setup & Connection Issues for Visual Basic Version 3.0

Last reviewed: October 26, 1995
Article ID: Q97415
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 3.0

SUMMARY

There are four possible problem areas that can contribute to a failure to connect to a database server when using ODBC and Visual Basic:

  • Having correct .INI file settings.
  • Having the correct DLLs in the right place.
  • Having the server information needed to connect to a server correctly.
  • Meeting the needs of Microsoft and Sybase SQL Servers.

MORE INFORMATION

The following describes each of the four areas, giving possible errors and problems that can arise if things are not set up correctly.

INI file settings

There are two .INI files (ODBCINST.INI and ODBC.INI) that must reside in the Windows directory and must contain correct information about the installed ODBC drivers and servers.

ODBCINST.INI contains the ODBC driver information needed to register new servers using the RegisterDataBase() statement in Visual Basic. Here is an example .INI file for the SQL Server driver that ships with Visual Basic:

   [ODBC Drivers]
   SQL Server=Installed

   [SQL Server]
   Driver=C:\WINDOWS\SYSTEM\sqlsrvr.dll
   Setup=C:\WINDOWS\SYSTEM\sqlsrvr.dll

The [ODBC Drivers] section tells the driver manager the names of the installed drivers. The [SQL Server] section tells the ODBC driver manager the names of the dynamic link libraries (DLLs) to use to access data from a server set up as a SQL Server. The order of the two sections and their entries is arbitrary.

ODBC.INI contains the data for each installed driver. The driver manager uses this information to determine which DLL to use to access data from a particular database backend. Here is an example of a file containing three data sources all using the SQL Server driver:

   [ODBC Data Sources]
   MySQL=SQL Server
   CorpSQL=SQL Server

   [MySQL]
   Driver=C:\WINDOWS\SYSTEM\sqlsrvr.dll
   Description=SQL Server on server MySQL
   OemToAnsi=No
   Network=dbnmp3
   Address=\\mysql\pipe\sql\query

   [CorpSQL]
   Driver=C:\WINDOWS\SYSTEM\sqlsrvr.dll
   Description=SQL Server on server CorpSQL
   OemToAnsi=No
   Network=dbnmp3
   Address=\\corpsql\pipe\sql\query

The first section tells the driver manager which sections appearing below it define the data source. As you can see, each entry has a value (in this case, SQL Server) that matches a value from the ODBCINST.INI file.

If the information on a data source is incorrect or missing, you may get the following error:

   ODBC - SQLConnect failure 'IM002[Microsoft][ODBC DLL] Data source
          not found and no default driver specified'

If the DLL listed on the Driver=... line cannot be found or is corrupt, the following error may occur:

   ODBC - SQLConnect failure 'IM003[Microsoft][ODBC DLL] Driver
          specified by data source could not be loaded'

ODBC and Driver DLLs

The following DLLs must be on the path or in the Windows system directory in order for ODBC to be accessible from Visual Basic:

   ODBC.DLL     - driver manager
   ODBCINST.DLL - driver setup manager
   VBDB300.DLL  - Visual Basic programming layer

If VBDB300.DLL is missing or corrupt, you see the following error in Visual Basic when you try to run the application:

   ODBC Objects require VBDB300.DLL

If either the ODBC.DLL or ODBCINST.DLL file is missing or corrupt, you see the following error in Visual Basic when you try to run the application:

  Cannot Find ODBC.DLL, File not Found

The SQL Server driver requires the following files:

   SQLSRVR.DLL  - actual driver
   SQLSETUP.DLL - driver setup routines
   DBNMP3.DLL   - named pipe routines needed by SQL server

If the SQLSRVR.DLL is missing or corrupt, you see the following error when calling the OpenDataBase() function with a SQL Server data source:

   ODBC - SQLConnect failure 'IM003[Microsoft][ODBC DLL] Driver
          specified by data source could not be loaded'

If the SQLSETUP.DLL is missing or corrupt, you see the following error when calling the RegisterDataBase statement with SQL Server as the driver name:

   The configuration DLL (C:\WINDOWS\SYSTEM\SQLSETUP.DLL) for the ODBC
   SQL server driver could not be loaded.

Server Information Needed to Connect to a Data Source

Certain information is needed to connect to a data source using the OpenDataBase() function. This information is obtainable from the server administrator in the case of SQL Server. The following is an example of a call to the OpenDataBase() function to connect to a SQL Server called CorpSQL as a user named Guest with password set to taco:

   Dim db As DataBase
   Set db = OpenDataBase( "corpsql", False, False, "UID=guest;PWD=taco")

If any of this information is missing, an ODBC dialog box appears to give a user a chance to supply the needed data. If the information is incorrect, the following error occurs:

   ODBC - SQLConnect failure '28000[Microsoft][ODBC SQL Server Driver]
          [SQL Server]  Login failed'

Information Specific to Microsoft SQL Servers

The Microsoft SQL Server ODBC Driver calls system catalog stored procedures on the SQL Server to obtain catalog information. If the driver attempts to connect to a SQL Server with an older version of these catalog stored procedures than those expected by the driver, the following error occurs:

   ODBC - SQL Connect Failure
   "08001" [Microsoft ODBC SQL Server Driver]
   'unable to connect to data source'number: 606'

Microsoft Knowledge Base Article Q137636 has information that the SQL Server system administrator can use to determine if these stored procedures need to be upgraded, and the procedure they should follow to do so.


Additional reference words: 3.00
KBCategory: kbinterop kbprg
KBSubcategory: APrgDataODBC


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 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.