错误code 3021 BOF或EOF为True或当前记录已被删除 [英] error code 3021 either bof or eof is true or the current record has been deleted

查看:1456
本文介绍了错误code 3021 BOF或EOF为True或当前记录已被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在它使用ADO一些视觉上的基本code Access 2003数据库调用。当我做了

I have an Access 2003 database with some visual basic code using ADO calls in it. When I do a

strsql0 = "SELECT lnk_stockitm.C_C FROM lnk_stockitm WHERE (((lnk_stockitm.C_C) Like 'T*'));"
newRS.Open strsql0, cn1, adOpenKeyset, adLockReadOnly  
newRS.movelast

我得到了'3021 BOF或EOF为True或当前记录已被删除......的错误。当我运行在相同的功能完全相同的查询没有WHERE子句,像这样

I get a '3021 either bof or eof is true or the current record has been deleted...' error. When I run the exact same query in the same function without the WHERE clause, like this

strsql0 = "SELECT lnk_stockitm.C_C FROM lnk_stockitm;

我得到56000条记录正确的结果。如果我贴的WHERE子句完整的SQL语句转换成常规查询,像这样

I get the correct result of 56,000 records. If I paste the full SQL statement with the WHERE clause into a regular query, like so

SELECT lnk_stockitm.C_C FROM lnk_stockitm WHERE (((lnk_stockitm.C_C) Like 'T*'));

它返回的结果(2800条记录)的正确的子集。

it returns the correct subset of the results (2800 records).

谁能告诉我什么,我做错了,或者有什么有趣的业务微软正在播放?

Can anyone tell me what I am doing wrong, or what funny business Microsoft is playing?

感谢。

推荐答案

通配符的区别是原因你从ADO和Access数据库中执行的差异。将您的语句中使用%,而不是*。根据经验,一般情况下,它可能是通过检查EOF之前调用 MoveLast 来封装你code是个好主意。如果你的查询有结果为零,它会每​​次都弹了出来。

The wildcard difference is the cause for difference between what you execute from ADO and within your access database. Convert your statement to use "%" rather than "*". As a general rule of thumb, it may be a good idea to encapsulate your code by checking for eof before calling MoveLast. If your query has zero results it'll bomb out every time.

strsql0 = "SELECT lnk_stockitm.C_C FROM lnk_stockitm WHERE (((lnk_stockitm.C_C) Like 'T*'));"
newRS.Open strsql0, cn1, adOpenKeyset, adLockReadOnly  

if not newRs.eof then
   newRS.movelast
else
  ' do something here if necessary to handle blank results
end if

这篇关于错误code 3021 BOF或EOF为True或当前记录已被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆