接ACCESS时出现80004005 Couldnt Lock File错误的解决

发表于:2007-06-30来源:作者:点击数: 标签:
适用于: Microsoft Active Server Pages Microsoft Data Access Components 1.5 Microsoft Data Access Components 2.0 Microsoft Data Access Components 2.1 Microsoft Data Access Components 2.1 SP1 Microsoft Data Access Components 2.1 SP2 Microsof
适用于:

Microsoft Active Server Pages
Microsoft Data Aclearcase/" target="_blank" >ccess Components 1.5
Microsoft Data Access Components 2.0
Microsoft Data Access Components 2.1
Microsoft Data Access Components 2.1 SP1
Microsoft Data Access Components 2.1 SP2
Microsoft Data Access Components 2.5
Microsoft Data Access Components 2.5 SP1
Microsoft Data Access Components 2.5 SP2
Microsoft Data Access Components 2.6


--------------------------------------------------------------------------------


This article was previously published under Q306441

问题的发生

当我们用 ActiveX Data Objects (ADO) 和Open DataBase Connection(ODBC)试图连接到一个MS Access数据库时,可能会返回如下错误消息:

Microsoft OLE DB Provider for ODBC Drivers error @#80004005@#
[Microsoft][ODBC Microsoft Access 97 Driver] Couldn@#t lock file.


发生的原因
以上这条错误消息的产生,是因为你没有对MS Access数据库创建lock file (.ldb)文件的权限。系统默认是,lock file (.ldb)的创建是在一个被看作是Microsoft Access .mdb 文件的同一目录下。

解决方法
按以下步骤进行:
1、准许访问数据库的用户(通常是IUSR_<computername> account)对这个共享文件夹完全支配。
2、由于lock file (.ldb)文件往往是被设置为只读(read-only),所以,在共享往往是被受限制的。那么,我们可以试着使用以下这段示范代码来改变连接方式:

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Mode = adModeShareDenyWrite @#8

@# 在 Adovbs.inc中的定义
@#---- 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


参考书目
要想了解更多,请点击以下连接:
174943 PRB: 80004005 "Couldn@#t Use @#(unknown)@#; File Already in Use"

183060 INFO: Troubleshooting Guide for 80004005 and Other Error Messages

原文转自:http://www.ltesting.net