Combining the results of 3 or 4 queries done on an ASP page into a single displayed table on a web page using VB

I am running an LDAP query against our Active Directory global catalog. Since we are running mixed mode, I have to do a separate query for each child domain but I want the results to be displayed in a single table that I can sort by last name. This is essentially a phone list lookup using our active directory as a database. I can do the data dip but I don't know how to append to the array I created...

Here is what I am doing: It only displays the last data from the last getrows()
I will want to dip into 6 separate servers and have all aggregated into a single, sorted, combined table....<%
   
   Dim RS
   Dim RS2
   set Conn = CreateObject("ADODB.Connection")
   set Command = CreateObject("ADODB.Command")
   Conn.Provider = "ADsDSOObject"
   Conn.Open "Ads Provider"
   Set RS = Server.CreateObject("ADODB.Recordset")
   Set RS2 = Server.CreateObject("ADODB.Recordset")
   set Command.ActiveConnection = Conn  'set the active connection

' Now we will loop through the results of our query
'   and build a table to display the Global Address List
 

'Assumes there is an open Connection object, Conn

'Create a Recordset
RS2.Open "SELECT cn,telephonenumber,mobile,ipphone,physicalDeliveryOfficeName,title  FROM 'LDAP://Server1:389/CN=Users,DC=parentdomain,DC=com' WHERE objectClass='*' and telephonenumber > '0'   ORDER BY cn " , Conn
RS.Open "SELECT cn,telephonenumber,mobile,ipphone,physicalDeliveryOfficeName,title  FROM 'LDAP://server2:389/CN=Users,dc=child,DC=parentdomain,DC=com' WHERE objectClass='*' and telephonenumber > '0'   ORDER BY cn " , Conn
'Now, read the Recordset into a 2d array
Dim aTable1Values
aTable1Values = RS.GetRows()
aTable1Values = RS2.GetRows()


 
Dim iRowLoop, iColLoop
For iRowLoop = 0 to UBound(aTable1Values, 2)
  For iColLoop = 0 to UBound(aTable1Values, 1)
%>

<%

  Next 'iColLoop

Next 'iRowLoop

numrows=ubound(aTable1Values,2)
fld_Name=5
fld_OfficePhone=4
fld_CellPhone=3
fld_IPPhone=2
fld_location=1
fld_Title=0


FOR rowcounter= 0 TO numrows
   response.write "<tr>" & vbcrlf
   name=aTable1Values(fld_name,rowcounter)
   OfficePhone=aTable1Values(fld_OfficePhone,rowcounter)
   CellPhone=aTable1Values(fld_CellPhone,rowcounter)
   IPPhone=aTable1Values(fld_IPPhone,rowcounter)
   location=aTable1Values(fld_location,rowcounter)
   Title=aTable1Values(fld_Title,rowcounter)
 
   name=cleanfield(name)
   OfficePhone=cleanfield(OfficePhone)
   CellPhone=cleanfield(CellPhone)
   IPPhone=cleanfield(IPPhone)
   Location=cleanfield(Location)
   Title=cleanfield(Title)
%>
<TD><% response.write "<td valign=top>" & name & "</td>" & vbcrlf %>      
<TD><% response.write "<td valign=top>" & OfficePhone & "</td>" & vbcrlf   %>  
<TD><% response.write "<td valign=top>" & CellPhone & "</td>" & vbcrlf   %>
<TD><% response.write "<td valign=top>" & IPPhone & "</td>" & vbcrlf   %>
<TD><% response.write "<td valign=top>" & Location & "</td>" & vbcrlf%>
<TD><% response.write "<td valign=top>" & Title & "</td>" & vbcrlf   %>  


<%
NEXT
%>


</body></html>
<%
SUB CloseAll
   rs.close
   set rs=nothing
   rs2.close
   set rs2=nothing
   conn.close
   set conn=nothing
END SUB

FUNCTION CleanField(parm1)
      cleanfield=parm1
      if isnull(parm1) then
         cleanfield="&nbsp;"
      end if
      if trim(parm1)="" then
         cleanfield="&nbsp;"
      end if
END FUNCTION
%>
chgrecAsked:
Who is Participating?
 
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
Carl TawnSystems and Integration DeveloperCommented:
You could try changing your first query to this:

SELECT cn,telephonenumber,mobile,ipphone,physicalDeliveryOfficeName,title  FROM 'LDAP://Server1:389/CN=Users,DC=parentdomain,DC=com' WHERE objectClass='*' and telephonenumber > '0'   ORDER BY cn UNION SELECT cn,telephonenumber,mobile,ipphone,physicalDeliveryOfficeName,title  FROM 'LDAP://server2:389/CN=Users,dc=child,DC=parentdomain,DC=com' WHERE objectClass='*' and telephonenumber > '0'   ORDER BY cn

Notice it uses the UNION statement to combine two queries into one recordset.  This would work on database tables, not sure if it will work with LDAP.  But you can always try it.

Hope this helps.
0
 
chgrecAuthor Commented:
Thanks, but apparently LDAP queries dont work that way....I have tried several sql style join type statements (including yours) and they dont work.....
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Anthony PerkinsCommented:
LDAP does not support UNION clauses.  You will have to create a recordset on the fly and append from your two queries or do the same with your arrays.
0
 
Anthony PerkinsCommented:
Here is a document that describes what SQL clauses it does support:
SQL Dialect
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/sql_dialect.asp
0
 
chgrecAuthor Commented:
Thats why I posted the question, I need to know how to take multiple queries, append the data in an array for sorting and display in a single  table....
How do I append an array?
0
 
chgrecAuthor Commented:
how do I do a request a refund? no one answered the question and I found out how to do what I wanted using port 3268 instead of port 389....
0
 
Anthony PerkinsCommented:
>>how do I do a request a refund?<<
Try clicking on the link Dan posted.
0
All Courses

From novice to tech pro — start learning today.