PRB: Error -2147467259 When You Try to Open the Same MDB File from Multiple Instances (307640)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.1
  • ActiveX Data Objects (ADO) 2.1 SP1
  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP5

This article was previously published under Q307640

SYMPTOMS

If you try to use a Microsoft Jet (Access) database from multiple instances of the same application either on the same computer or on different computers, you receive the following error message:
-2147467259 Error ODBC Microsoft Access Driver: The database has been placed in a state by an unknown user that prevents it from being opened or locked.
This error occurs with both the Microsoft ODBC Driver for Access and the OLE DB Provider for Jet.

CAUSE

To run an .mdb file by multiple instances, Jet makes use of a lock delay and retry interval. However, under high load conditions, you may exceed these intervals.

RESOLUTION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: The following workaround extends the retry delay for Jet so that you can use additional instances. However, it is not recommended that you use this workaround if a high number of updates are being formed; this workaround is intended only for reading databases.

You can add the following sample error handler to your code. Please note that this handler only works with ADO and uses the Sleep function, which you must declare in your general declarations section.
RetryHandler:
' Retry until MAX_RETRIES are hit to increment your error count.
errorcount = errorcount + 1
If errorcount < MAX_RETRIES Then

' Sleep a random amount of time, and retry the same operation.
    Sleep Int(MAX_SLEEP_INTERVAL * Rnd) + 1
    Resume
Else
' Retries did not help. Show the error, and fall out.
    MsgBox Err.Number & " " & Err.Description
    Exit Sub
End If
				

STATUS

This behavior is by design.

MORE INFORMATION

The above-mentioned workaround is only for read-only mode. Microsoft does not support placing Jet .mdb files under high user load. Microsoft strongly recommends that you use Microsoft SQL Server or Microsoft Data Engine (MSDE) instead of Access when high user loads (that is, more than 15 instances) are required or anticipated, especially when updating is required.

REFERENCES

For more information about the Sleep function, refer to the MSDN Library documentation.

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kberrmsg kbnofix kbprb KB307640