Solved

Recordset From ADSI Limited To 5000 Records

Posted on 2008-10-29
6
710 Views
Last Modified: 2013-11-30
Please can someone kindly help me with this (VB code running within a SQL DTS)...
      
      Dim SQLConnectionObj, SQLConnectionStr
       Set SQLConnectionObj=CreateObject("ADODB.Connection")
       SQLConnectionStr="[connection string details here]"

       Dim MyDirectoryConnectionObj, MyDirectoryRecordSet
       Set MyDirectoryConnectionObj=CreateObject("ADODB.Connection")
      Set MyDirectoryRecordSet=CreateObject("ADODB.Recordset")

      SQLConnectionObj.Open SQLConnectionStr

      SQLConnectionObj.Execute "CREATE TABLE dbo.Lockdown_MyDirectoryFieldsFromDTS " & _
          "(" & _
          "UserID nvarchar(50), " & _
          "UserLastName nvarchar(255), " & _
          "UserFirstName nvarchar(255), " & _
          "ManagerID nvarchar(50), " & _
          ");"

      Dim FirstLetter, sBase, sFilter, sAttribs, sDepth, sQuery, ManagerString, MgrIDStart, MgrIDEnd
      Dim UserID, UserLastName, UserFirstName, ManagerID
      MyDirectoryConnectionObj.Open "DataSource=Active Directory Provider;Provider=ADsDSOObject"      

      For FirstLetter=65 To 90
            sBase="<LDAP://MyDirectoryDIR>"
            sFilter="(&(employeeType=ACTIVE)(sn=" & CHR(FirstLetter) & "*))"
            sAttribs="uid,sn,givenName,Manager"
            sDepth="subTree"
            sQuery=sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth
            Set MyDirectoryRecordSet=MyDirectoryConnectionObj.Execute(sQuery)
            
                  While Not MyDirectoryRecordSet.EOF

                        If ISNULL(MyDirectoryRecordSet(0)) Then
                              UserID="ID Not Found"
                        Else
                              UserID=Replace(MyDirectoryRecordSet(0),"'","''")
                        End If

                        If ISNULL(MyDirectoryRecordSet(1)) Then
                              UserLastName="Last Name Not Found"
                        Else
                              UserLastName=Replace(MyDirectoryRecordSet(1),"'","''")
                        End If

                        If ISNULL(MyDirectoryRecordSet(2)) Then
                              UserFirstName="First Name Not Found"
                        Else
                              UserFirstName=Replace(MyDirectoryRecordSet(2),"'","''")
                        End If

                        If ISNULL(MyDirectoryRecordSet(3)) then
                              ManagerID="ID Not Found"
                        Else
                              ManagerString=Replace(MyDirectoryRecordSet(3),"'","''")
                              MgrIDStart=Instr(ManagerString,"OU=")+3
                              MgrIDEnd=Instr(MgrIDStart,ManagerString,",")-1
                              ManagerID=Mid(ManagerString,MgrIDStart,(MgrIDEnd-MgrIDStart)+1)      
                        End If
                        
                        SQLConnectionObj.Execute "INSERT INTO Lockdown_MyDirectoryFieldsFromDTS VALUES (" & _
                        "'" & UserID & "'," & _
                        "'" & UserLastName &  "'," & _
                        "'" & UserFirstName &  "'," & _
                        "'" & ManagerID & "')"
            
                        MyDirectoryRecordSet.MoveNext

                  Wend

      Next

For some reason, each recordset appears to be limited to returning just 5000 records. I have played around with several parameters of the RecordSet object such as MaxRecords, PageSize, CacheSize however RecordCount always equals 5000.

Not sure where else to turn!!!  If not a RecordSet issue, could it be a limitation of ADSI, ODBC or something else?  Can't seem to find a similar issue elsewhere (with 1000 yes [for ADSI] but not 5000?).

Many thanks,
Tony
0
Comment
Question by:antdow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:HoggZilla
ID: 22831571
There was a bug in MDAC that related to 5000 record limits. Check this link and make sure your MDAC is updated.
http://support.microsoft.com/kb/248668
 
0
 
LVL 17

Expert Comment

by:HoggZilla
ID: 22831602
Here is the MSDN site for MDAC.
http://msdn.microsoft.com/en-us/data/aa937730.aspx
0
 
LVL 1

Author Comment

by:antdow
ID: 22831668
Thanks for the response but the symptoms don't appear to match my own.  I am not using the Oracle driver and I do not receive any error messages, just the recordcount does not go above 5000?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:HoggZilla
ID: 22831737
I can tell you this, the ADODB Recordset does not have a limitation itself. The only limit is based on available system resources. I will keep looking for a solution.
0
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 22833206
It certainly looks like the PageSize is the way to go....
Dim Com As New Command

Com.Properties("Page Size") = 999
Com.Properties("Timeout") = 30     ' Seconds
Com.Properties("Cache Results") = False     ' Do not cache the result set.
http://msdn.microsoft.com/en-us/library/aa746459(VS.85).aspx
0
 
LVL 1

Author Comment

by:antdow
ID: 22833677
Thank you Graye, it works!  I was setting Page Size on the RecordSet - which appeared to be valid - (as I didn't have a Command object since executing SQL directly from the Connection object).  Now that I have added an ADO Command object to the mix, I am the proud owner of a 12,000+ strong recordset. Thanks again for your help!
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question