I am trying to write a series of values into an array. If I set up the array by declaring a number of 'slots' the script works fine but if I try to use a dynamic array I get the following error:
Microsoft VBScript runtime error '800a0009'
Subscript out of range
/assets2/getlist2.asp, line 27
My code is as follows:
<%
Dim HostsArray()
counter=0
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objDomain = getObject("LDAP://rootDse")
Domain = objDomain.Get("defaultNamingContext")
LDPATH = Chr(39) & "LDAP://" & Domain & Chr(39)
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from " & LDPATH _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
HostsArray(counter)= objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
counter=counter+1
Loop
%>
Any ideas?
Thanks very much
Ed
Microsoft VBScript runtime error '800a0009'
Subscript out of range
/assets2/getlist2.asp, line 27
My code is as follows:
<%
Dim HostsArray()
counter=0
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objDomain = getObject("LDAP://rootDse")
Domain = objDomain.Get("defaultNamingContext")
LDPATH = Chr(39) & "LDAP://" & Domain & Chr(39)
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from " & LDPATH _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
HostsArray(counter)= objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
counter=counter+1
Loop
%>
Any ideas?
Thanks very much
Ed