PRB: Troubleshooting Error 80004005 "Couldn't Lock File" in ASP


When you use ActiveX Data Objects (ADO) and ODBC to try to connect to a Microsoft Access database, you may receive the following error message:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access 97 Driver] Couldn't lock file.


This error message occurs because you do not have the correct permissions to create the lock file (.ldb) for a Microsoft Access database. By default, a lock file is created in the same folder as the Microsoft Access .mdb file.


To resolve this problem, follow these steps:
  1. Grant the user who is accessing the database (usually the IUSR_<computername> account) full control to the share or folder.
  2. Sometimes permissions are restricted on the share because the file is intended to be read-only. You may want to try to change the connection mode, which the following code demonstrates:
       Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Mode = adModeShareDenyWrite '8

    '---- ConnectModeEnum Values ----
    'Const adModeUnknown = 0
    'Const adModeRead = 1
    'Const adModeWrite = 2
    'Const adModeReadWrite = 3
    'Const adModeShareDenyRead = 4
    'Const adModeShareDenyWrite = 8
    'Const adModeShareExclusive = &Hc
    'Const adModeShareDenyNone = &H10


This behavior is by design.


For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
174943 PRB: 80004005 "Couldn't Use '(unknown)'; File Already in Use"

รหัสบทความ: 306441 - การตรวจสอบครั้งสุดท้าย: 4 ส.ค. 2008 - ฉบับแก้ไข: 1