vba -编写访问数据库的应用层程序,经常catch出的一些错误

同样的错误信息,也可能并不是只有唯一产生错误的原因。

 

Microsoft JET Database Engine error ‘80004005′
Could not find file ‘c:\inetpub\wwwroot\db.mdb’.
原因:找不到指定的数据库文件。

解决:根据错误信息中的路径,查看文件是否存在或者是否写错文件名,要么将文件建立在正确的位置,要么修正 Server.MapPath() 的参数中的文件路径。产生这个错误,一般参数仅有文件名,区别于下面的错误。

 

Microsoft JET Database Engine error ‘80004005′
‘c:\inetpub\wwwroot\database\db.mdb’ is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
原因:路径不正确。

解决:同第一个错误产生的情况不一样,这是因为 Server.MapPath() 方法参数中包含有路径信息“database/”,但是在这个路径中,找不到需要的文件。所以检查文件是否在正确的位置或者路径是否拼写错误。

 

Microsoft JET Database Engine error ‘80040e37′ The Microsoft Jet database engine cannot find the input table or query ‘myTable’. Make sure it exists and that its name is spelled correctly.
原因:SQL 语句中指定的表并不存在。

解决:检查是否拼写错误表名,或者建立对应的表。

 

Microsoft JET Database Engine error ‘80040e10′ No value given for one or more required parameters.
原因:查询的字段不存在。

解决:检查查询语句中的字段是否都村在表中,或者是否拼写错了字段名。

 

ADODB.Field error ‘80020009′ Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
原因:记录为空。

解决:试图访问空的表中的字段值,所以想取值之前检查表中记录是否为空即可。

 

ADODB.Recordset error ‘800a0cc1′ Item cannot be found in the collection corresponding to the requested name or ordinal.
原因:字段没有找到。

解决:试图访问在 SQL 中没有申明的字段,即纪录集中没有对应的数据。要么在 SQL 语句中增加相应字段,要么删除读取该字段的代码。

 

Microsoft JET Database Engine error ‘80004005′ Could not use ”; file already in use.
原因:文件在使用中。

解决:其它程序打开了相应的数据库文件,例如 Access 中。在其它程序中关闭对数据库文件的打开即可。

 

ADODB.Recordset error ‘800a0e7d’ The connection cannot be used to perform this operation. It is either closed or invalid in this context.

原因:将 ADODB.Connection 写作了 ADODB.Recordset 。

解决:更正上述错误即可。另外,如果将 Connection 写作了其它单词,得到的错误信息有所不同——会被告知 Server.CreateObject 无法创建对象。

 

Microsoft VBScript runtime error ‘800a01c2′ Wrong number of arguments or invalid property assignment
原因:将 ADODB.Recordset 写成了 ADODB.Connection。

解决:同上。

 

ADODB.Recordset error ‘800a0bb9′ Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
原因:Recordset 对象的 Open 方法参数不正确。

解决:检查各部分参数是否正确,尤其是变量名和游标类型参数等。

 

ADODB.Recordset error ‘800a0cb3′ Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
原因:当前记录集不支持更新。
解决:检查所定类型参数是否正确。
posted @ 2023-02-02 17:55  vba是最好的语言  阅读(152)  评论(0编辑  收藏  举报