Solved

VBscript end of record set not finishing

Posted on 2014-01-16
4
478 Views
Last Modified: 2014-01-22
I’m not sure if this will make any sense.. but
 I’m making an VBscript that connects to Active Directory and then imports the records  into Sql.

The Record set is not looping all the way to the end.  It see all the records (+8000) in the logs but is doesn't make it pass 5000 records when writing to SQL or passed 7000 records when just writing to a TXT file instead of sql.

Any ideas?

Some of the code....
* the script does echo out the right number of records in AD.
Sub GetAttribs
	intCount = 1
	objCommand.CommandText = FormatLDAPString (UserOUString, "user", strFilter, strFields)
'WScript.Echo "Executing Query..."

	Set objRS = objCommand.Execute
'WScript.Echo "Records found:   " & objRS.RecordCount
'================================================================
	With objRS
		.MoveFirst
		Do Until .EOF
			strADUsername          = .Fields("sAMAccountName").Value
			‘more items listed if full script (23 total)
'===========================================
'Step: Write to SQL or Txt
'===========================================
' .......
'===========================================
'Step: End Loops
'===========================================
			intCount = intCount + 1
		    .MoveNext
		Loop
	End With
	objRS.Close

Open in new window

0
Comment
Question by:POOK-101
  • 2
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 39787274
This is more often a result of the .PageSize property in the LDAP query.  It should be set to 1000 to allow more records to be returned.

As a simple test, can you just do this:
intRecord = 0
While Not objRS.EOF
   intRecord = intRecord + 1
   WScript.Echo intRecord
   objRS.MoveNext
Wend

Open in new window


and see the record count.

Regards,

Rob.
0
 

Assisted Solution

by:POOK-101
POOK-101 earned 0 total points
ID: 39789193
So i'm not sure why, but when i  hide the WScript.Echo command and the script finished with out problems. (all 8000 plus records)  I had about 15 different echo commands in the script.
Also i ran the script outside my VBS editor. (PrimalScipt)

How i hide the commands, so i can turn them back on if needed.

If iDebugMode = 1 Then WScript.Echo "Processing DB Functions Now"

Open in new window


Not sure why this worked.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39790571
Not sure. If it was running under WScript, or was somehow hidden, maybe you couldn't see the echos. Glad it works anyway.
0
 

Author Closing Comment

by:POOK-101
ID: 39799476
I found the fix, but the reply gave me an idea of what to try.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

816 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

11 Experts available now in Live!

Get 1:1 Help Now