ACC2000: OpenDatabase Method Does Not Use Jet LoginTimeout

ID: Q202037


The information in this article applies to:

This article applies only to a Microsoft Access database (.mdb).

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

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

The default ODBC Login timeout setting for Microsoft Jet databases is 20 and is stored, depending on the version, in the following registry key:

HKEY_LOCAL_MACHINE\SOFTWAREMicrosoft\Jet\4.0\Engines\ODBC\LoginTimeout
You can change this value from the default of 20; however, the new value 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 Microsoft products listed at the beginning of this article.


MORE INFORMATION

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

Steps to Reproduce Problem

  1. Create an ODBC System DSN named TEST that points to some ODBC database.


  2. In Control Panel, click the ODBC icon and start ODBC tracing.


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


  4. Click Start, click Run, type regedit in the Open box, and then click OK.


  5. In Registry Editor, change the following registry key to 50 with a type of Decimal:


  6. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4\Engines\ODBC\LoginTimeout
  7. Open a Microsoft Access database and press CTRL+G.


  8. Type the following line of code in the Immediate window, and then press ENTER:


  9. 
    Set db=DBEngine.OpenDatabase("",false,false,"odbc;DSN=TEST" ) 
  10. 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 the Microsoft Jet database engine is using the registry setting and calls SQLSetConnectOption with the LoginTimeout value of 50.


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


  12. Open another Microsoft Access database and run the following line of code from the Immediate window:


  13. 
    Set db=opendatabase("",false,false,"odbc;DSN=TEST" ) 
Checking ODBC trace, note that the Jet database engine does NOT use the registry setting and calls SQLSetConnectOption with the default LoginTimeout value of 20.

Additional query words: pra


Keywords          : kbdta PgmObj 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 13, 1999