Web Development



How do I format the query for an array for description field?

By oskiller ·
After some searching, I found out that the reason I am receiving a type mismatch on the description field is that it is an array, but for the life of me I cannot figure out the formatting to make this work:


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location, Description from 'LDAP:// *redacted* ' Where objectClass='computer'"
objCommand.Properties("Page Size") = 1500
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
Wscript.Echo "Description: " & objRecordSet.Fields("Description").Value

It finds the first computer fine because the Description field is blank, but chokes on a type mismatch on the next system.

Basically, I'm trying to return the Name, Location and Description field for every computer to see where there are blanks, mismatches etc. I've found plenty of things that state the description field is an array and show various things, but I have not been able to make it work - either I'm inserting it in the wrong place or I have it incorrect.

This seems to be the most common thing I am finding:

arrDesc = objRecordSet.Fields("description").value
If IsNull(arrDesc) Then
strDesc = ""
For Each strLine In arrDesc
'strDesc = strGroupName & " | " & strLine
strDesc = strline
End If

I'm pulling my hair out on this one.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums