同样的错误信息,也可能并不是只有唯一产生错误的原因。
Could not find file ‘c:\inetpub\wwwroot\db.mdb’.
原因:找不到指定的数据库文件。
解决:根据错误信息中的路径,查看文件是否存在或者是否写错文件名,要么将文件建立在正确的位置,要么修正 Server.MapPath() 的参数中的文件路径。产生这个错误,一般参数仅有文件名,区别于下面的错误。
‘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/”,但是在这个路径中,找不到需要的文件。所以检查文件是否在正确的位置或者路径是否拼写错误。
原因:SQL 语句中指定的表并不存在。
解决:检查是否拼写错误表名,或者建立对应的表。
原因:查询的字段不存在。
解决:检查查询语句中的字段是否都村在表中,或者是否拼写错了字段名。
原因:记录为空。
解决:试图访问空的表中的字段值,所以想取值之前检查表中记录是否为空即可。
原因:字段没有找到。
解决:试图访问在 SQL 中没有申明的字段,即纪录集中没有对应的数据。要么在 SQL 语句中增加相应字段,要么删除读取该字段的代码。
原因:文件在使用中。
解决:其它程序打开了相应的数据库文件,例如 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 无法创建对象。
原因:将 ADODB.Recordset 写成了 ADODB.Connection。
解决:同上。
原因:Recordset 对象的 Open 方法参数不正确。
解决:检查各部分参数是否正确,尤其是变量名和游标类型参数等。
原因:当前记录集不支持更新。
解决:检查所定类型参数是否正确。