我有一个非常简单的查询,它只返回一条记录。当我尝试从唯一记录中的唯一列中获取值时,我得到“BOF或EOF为True,或者当前记录已被删除。请求的操作需要当前记录”。这里发生了什么事?如果RecordCount为0,并且我已验证记录集确实包含记录,则导致错误的代码甚至不会执行。
代码如下。尝试设置strDN时抛出错误。这非常简单,但我不知道我错在哪里。
编辑以包含命令
<LDAP://DC=something,DC=com>;(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(employeeID=01234567));distinguishedName;subtree
Set adoRecordset = adoCommand.Execute
If adoRecordset.RecordCount > 0 Then
strDN = adoRecordset.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & strDN)
objGroup.add(objUser.ADsPath)
End if发布于 2010-06-30 02:51:26
recordcount属性将光标留在记录集的末尾,因此您无法获取记录(eof=true),必须先移动。使用不同的游标类型,因为默认游标类型为forward only:
'' Assign cursorType that allows forward and backward movement.
adoRecordset.cursorType = 3 ''adOpenStatic发布于 2010-06-30 02:42:50
我使用
If Not adoRecordset.EOF And Not adoRecordset.BOF Then
...
End If对于这个场景
发布于 2010-06-30 02:24:09
-编辑-查看以下链接。列出了一些原因,以及大多数原因的解决方案:
http://classicasp.aspfaq.com/general/why-do-i-get-bof-or-eof-errors.html
在这一点上我错了--谢谢,戴夫,我相信在尝试获取记录集中字段的值之前,您需要调用adoRecordset.MoveNext (或其他调用)。
https://stackoverflow.com/questions/3143540
复制相似问题