BUG: CreateDynaset Holds Lock on Index if No Records Return

Last reviewed: June 28, 1996
Article ID: Q153018
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SYMPTOMS

After opening a Dynaset that contains no records with a SQL statement that refers to an indexed field, attempting to access that table from another application can cause the error:

   "Couldn't save; currently locked by user Foo on machine Bar"

CAUSE

The error occurs because the Jet engine is not, by default, releasing the lock on the index page after opening the Recordset. This behavior only occurs when the Recordset returned contains no records. It occurs with Jet 2.5 and Jet 3.0, but doesn't occur with Jet 1.1.

WORKAROUND

To work around this problem, add a call to the Idle method of the DBEngine object immediately after the call to OpenRecordset. Add the following line of code:

   DBEngine.Idle dbFreeLocks

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps To Reproduce Problem

  1. Start Visual Basic 4.0. Form1 is created by default.

  2. Open the References dialog (Tools Reference), and add a reference to either DAO 2.5 (16-bit) or DAO 3.0 (32-bit).

  3. Add a single Command button to Form1.

  4. Add the following code to the form:

       Private Sub Command1_Click()
          Set db = OpenDatabase("BIBLIO.MDB")
          Set rs = db.OpenRecordset("Select * From Authors Where AU_ID > _
                   200", dbOpenDynaset)
       End Sub
    
    

  5. From the Insert menu, choose Module, and insert a single code module.

  6. Add the following code to the module:

    Global rs As Recordset Global db As Database

  7. Press the F5 key or select Start from the Run menu to run the application. Click on the Command button to open the database, and create a Recordset.

  8. Start another instance of Visual Basic. From the Add-Ins menu, choose Data Manager, and start the Data Manager application.

  9. In Data Manager, open the same BIBLIO database that was opened in step 4. Open the Authors table and attempt to add a new record. When the update is attempted, Data Manager will give the error mentioned above.


Additional reference words: 4.00 vb4win vb4all
KBCategory: kbprg kbbuglist
KBSubcategory: APrgData



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: June 28, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.