ACC: OpenDatabase Method does not Use Jet LoginTimeout Setting

ID: Q195946


The information in this article applies to:



IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.

SYMPTOMS

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

The default ODBC LoginTimeout property setting for Microsoft Jet databases is 20. Depending on which version of Microsoft Access you have, the ODBC LoginTimeout setting is stored in the following registry key.

In Microsoft Access 97
----------------------


     HKEY_LOCAL_MACHINE\SOFTWARE
          Microsoft\Jet\3.5\Engines\ODBC\LoginTimeout 

In Microsoft Access 7.0
-----------------------

     HKEY_LOCAL_MACHINE\SOFTWARE
          Microsoft\Jet\3.0\Engines\ODBC\LoginTimeout 

You can change the ODBC LoginTimeout property value from the default of 20; however, the new value that you set will not be used in the OpenDatabase method of the current database, as in the following line:

   Set db=OpenDatabase("",false,false,"odbc;DSN=TEST" ) 


RESOLUTION

If you have changed the registry key to something other than the default of 20, and you want to use that new value with the OpenDatabase method, you should include the DBEngine object, as in the following line:


   set db=DBEngine.OpenDatabase("",false,false,"odbc;DSN=TEST" ) 


STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Access listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Problem

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).
  1. Create an ODBC System DSN named TEST that points to some ODBC database.


  2. Open the ODBC tool in Control Panel and start ODBC tracing.


  3. Delete the current ODBC trace file if one exists.


  4. Click Start, click Run, and then type Regedit in the Open box. Press ENTER.


  5. In Regedit change the following registry key to 50 with a Type of Decimal.

    In Microsoft Access 97
    ----------------------
    
            HKEY_LOCAL_MACHINE\SOFTWARE
               Microsoft\Jet\3.5\Engines\ODBC\LoginTimeout 

    In Microsoft Access 7.0
    -----------------------
    
            HKEY_LOCAL_MACHINE\SOFTWARE
               Microsoft\Jet\3.0\Engines\ODBC\LoginTimeout 


  6. Open a Microsoft Access database and press CTRL+G to open the Debug Window.


  7. Type the following line of code and press ENTER to run it: set db=DBEngine.OpenDatabase("",false,false,"odbc;DSN=TEST" )


  8. Open the ODBC trace file in Microsoft Notepad and look for SQLSetConnectOption with the <LoginTimeout> value. Note that the DWORD value for <LoginTimeout> is 50. This indicates that Microsoft Jet is using the registry setting and calls SQLSetConnectOption with the LoginTimeout value of 50.


  9. Close the database and delete the ODBC trace log.


  10. Open another Microsoft Access database and run the following line of code from the Debug window: set db=OpenDatabase("",false,false,"odbc;DSN=TEST" ) Check the ODBC trace log again. Note that Jet does NOT use the registry setting and calls SQLSetConnectOption with the default LoginTimeout value of 20.


Additional query words:


Keywords          : kbdta ODBCGen 
Version           : WINDOWS:7.0,97
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 21, 1999