ACC95: RegisterDatabase Example in Help Causes Error

ID: Q156225

The information in this article applies to:

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          : kberrmsg kbprg OdbcOthr 
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86

Last Reviewed: August 30, 1997