?
Solved

VBscript end of record set not finishing

Posted on 2014-01-16
4
Medium Priority
?
481 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
[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
  • 2
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

801 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