Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:37:33+00:00 2026-06-12T22:37:33+00:00

I have to call recordCount function to get the count of recordset. But once

  • 0

I have to call recordCount function to get the count of recordset.
But once I call recordCount function, the recordset is out of control.

...
Dim objRootDSE, strDNSDomain, adoCommand, adoConnection
Set adoCommand = CreateObject("ADODB.Command")
'Set adoRecordset = adoCommand.Execute
Set adoRecordset = Server.CreateObject ("ADODB.Recordset") 
adoRecordset.cursorType = 3
adoRecordset.CursorLocation = adUseClient 
adoRecordset = adoCommand.Execute
...


totalcnt = adoRecordset.recordCount

If totalcnt > 0 Then 
...
    Do until adoRecordset.EOF
        ' Retrieve values... But it fails because it seems adoRecordset is in EOF
        ...

So I use movefirst and try to retrieve values.

If adoRecordset.recordCount > 0 Then 
                                            adoRecordset.movefirst
    ...

But it occurs an error(below is translated by google)

ADODB.Recordset 오류 '800a0bcd' 
BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

If I didn’t call recordCount, there’s no problem. But I should know the count of record.

The whole code is :

    <%
'On Error Resume next
 Dim objRootDSE, strDNSDomain, adoCommand, adoConnection
 Dim strBase, strFilter, strAttributes, strQuery, adoRecordset
 Dim strDN, strUser, strPassword, objNS, strServer
 Dim name,company,physicalDeliveryOfficeName

 Const ADS_SECURE_AUTHENTICATION = 1
 Const ADS_SERVER_BIND = 0

 ' Specify a server (Domain Controller).
 strServer = "my_ad_server_domain"

 ' Specify or prompt for credentials.
 strUser = "my_account"
 strPassword = "my_passwrd"

 ' Determine DNS domain name. Use server binding and alternate
 ' credentials. The value of strDNSDomain can also be hard coded.
 Set objNS = GetObject("LDAP:")
 Set objRootDSE = objNS.OpenDSObject("LDAP://" & strServer & "/RootDSE", _
      strUser, strPassword, _
      ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION)
 strDNSDomain = objRootDSE.Get("defaultNamingContext")

 ' Use ADO to search Active Directory.
 ' Use alternate credentials.
 Set adoCommand = CreateObject("ADODB.Command")
 Set adoConnection = CreateObject("ADODB.Connection")
 adoConnection.Provider = "ADsDSOObject"
 adoConnection.Properties("User ID") = strUser
 adoConnection.Properties("Password") = strPassword
 adoConnection.Properties("Encrypt Password") = True
 adoConnection.Properties("ADSI Flag") = ADS_SERVER_BIND _
      Or ADS_SECURE_AUTHENTICATION
 adoConnection.Open "Active Directory Provider"
 Set adoCommand.ActiveConnection = adoConnection

 ' Search entire domain. Use server binding.
 strBase = "<LDAP://" & strServer & "/" & strDNSDomain & ">"

 ' Search for all users.
 strFilter = "(&(objectCategory=user)(ExADObjectStatus=10)(samaccountname=*"&"my_search_value"&"*))"

 ' Comma delimited list of attribute values to retrieve.
 strAttributes = "name,company,physicalDeliveryOfficeName"

 ' Construct the LDAP query.
 strQuery = strBase & ";" & strFilter & ";" _
      & strAttributes & ";subtree"

 ' Run the query.
 adoCommand.CommandText = strQuery
 adoCommand.Properties("Page Size") = 100
 adoCommand.Properties("Timeout") = 60
 adoCommand.Properties("Cache Results") = False
 Set adoRecordset = adoCommand.Execute




if not adoRecordset.EOF then 
    totalcnt = adoRecordset.recordCount 
    If totalcnt > 0 Then  
    Response.write 111
        Do until adoRecordset.EOF
            name = adoRecordset.Fields("name").Value
              company = adoRecordset.Fields("company").Value
              physicalDeliveryOfficeName = adoRecordset.Fields("physicalDeliveryOfficeName").Value
              Response.Write name & "<br/>"
              Response.Write company & "<br/>"
              Response.Write physicalDeliveryOfficeName
              adoRecordset.MoveNext
        Loop 
    end if 
end if 



 ' Clean up.
 adoRecordset.Close
 adoConnection.Close 
%>

It shows only one result of record.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:37:34+00:00Added an answer on June 12, 2026 at 10:37 pm

    You can try to face the problem from a different angle. Instead of trying to fix the internal recordCount property (which you can’t) simply count the records yourself:

    totalcnt = 0
    Do until adoRecordset.EOF
        totalcnt = totalcnt + 1
        adoRecordset.MoveNext
    Loop
    
    If totalcnt>0 Then
        adoRecordset.MoveFirst
        Do until adoRecordset.EOF
            name = adoRecordset.Fields("name").Value
            '...
            adoRecordset.MoveNext
        Loop
    End If
    

    Update: Looks like in that specific case, the MoveFirst just fails, maybe because it’s LDAP and not ordinary query from a database. To bust this once and for all, you can populate your own collection when iterating the records then use that collection as much as you like:

    Dim oData, oField, tempArray
    Set oData = Server.CreateObject("Scripting.Dictionary")
    totalcnt = 0
    For Each oField In adoRecordset.Fields
        oData.Add oField.Name, Array()
    Next
    Do until adoRecordset.EOF
        For Each oField In adoRecordset.Fields
            tempArray = oData(oField.Name)
            ReDim Preserve tempArray(UBound(tempArray) + 1)
            tempArray(UBound(tempArray)) = oField.Value
            oData(oField.Name) = tempArray
        Next
        totalcnt = totalcnt + 1
        adoRecordset.MoveNext
    Loop
    adoRecordset.Close
    
    Dim x
    If totalcnt>0 Then
        Response.Write("found total of " & totalcnt & " records<br />")
        For x=0 To totalcnt-1
            name = oData("name")(x)
            company = oData("company")(x)
            physicalDeliveryOfficeName = oData("physicalDeliveryOfficeName")(x)
            Response.Write name & "<br/>"
            Response.Write company & "<br/>"
            Response.Write physicalDeliveryOfficeName
        Next
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to call a stored procedure and get the results. I know there
I have a call back url, that i'm am pulling out the Lat and
<div class=interactionLinksDiv> <a href=javascript:toggleReplyBox('.$fullname.','.$current_id.','.$current_id.','.$id.','.$thisRandNum.')>REPLY</a> </div> I have call the javascript function toggleReplyBox with five
I have a call to a get action method with a list of query
I have a call like this, SomeList.Fetch(x => SomeCondition).OrderBy(x => x.GetType().GetProperty(sort).GetValue(x, null)) I get
I have a call that needs to determine if a field has changed. But
I want capture the Home key, but I have call setType(WindowManager.LayoutParam.TYPE_KEYGUARD) in onAttachedToWindow ,
I have to call a value from the first array to the next. But
I have a call like this: $(#ContextMenuModal).height($(body).height()); However $(body).height() returns undefined when I view
I have a call to powershell.exe that looks like this, and which works from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.