Solved

Recordset From ADSI Limited To 5000 Records

Posted on 2008-10-29
6
690 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now