ACC95: RegisterDatabase Example in Help Causes Error

Last reviewed: August 29, 1997
Article ID: Q156225
The information in this article applies to:
  • Microsoft Access version 7.0

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you use the Example code for the RegisterDatabase method in Microsoft Access for Windows 95 version 7.0 Help, you may receive the following error message:

   Run-time error '3146':

   ODBC--call failed.

CAUSE

In the Example code, the following string expression assigned to the strAttribs variable is incomplete:

   strAttribs = "Description=SQL Server on server PtLudlow" & _
       Chr$(13) & "OemToAnsi=No" & Chr$(13) & "Network=DBNMP3" & _
       Chr$(13) & "Address=\\PTLUDLOW\PIPE\SQL\QUERY" & Chr$(13) & _
       "Database=MySQLDb"

Also, the string expression for the SQL Server driver argument of the RegisterDatabase method is incorrect:

   DBEngine.RegisterDatabase "PtLudlow", "SQL Server 32", True, strAttribs

RESOLUTION

To correct the RegisterDatabase Example code, add a Server attribute to the strAttribs expression as follows:

   strAttribs = "Description=SQL Server on server PtLudlow" & _
       Chr$(13) & "OemToAnsi=No" & Chr$(13) & "Network=DBNMP3" & _
       Chr$(13) & "Address=\\PTLUDLOW\PIPE\SQL\QUERY" & Chr$(13) & _
       "Database=MySQLDb" & Chr$(13) & "Server=PtLudlow"

Then change "SQL Server 32" to "SQL Server" in the driver argument of the RegisterDatabase method as follows:

   DBEngine.RegisterDatabase "PtLudlow", "SQL Server", True, strAttribs

MORE INFORMATION

The keyword "Server" is a required attribute for setting up the SQL Server ODBC driver, which is what this example uses. "Server" may not be a required attribute for other ODBC drivers.

The driver argument of the RegisterDatabase method is a string expression that is the name of the ODBC driver. For the SQL Server ODBC driver, that name should be "SQL Server" instead of "SQL Server 32." To find the name of any ODBC driver available on your computer, click the ODBC icon in Control Panel, and then click the Add button. The names of all installed ODBC drivers appear in the Installed ODBC Drivers box.

REFERENCES

For more information about the RegisterDatabase method, search for "RegisterDatabase," using the Microsoft Access for Windows 95 Help Index.

Keywords          : DcmHlp kberrmsg kbprg PgmOthr OdbcOthr
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbdocerr


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


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