Solved

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

Posted on 2004-08-11
10
193 Views
Last Modified: 2010-05-02
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
%>
0
Comment
Question by:chgrec
[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
10 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11778685
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
 

Author Comment

by:chgrec
ID: 11779459
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 11780370
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 11780375
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
 

Author Comment

by:chgrec
ID: 11783006
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
 

Author Comment

by:chgrec
ID: 12377012
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 12489885
>>how do I do a request a refund?<<
Try clicking on the link Dan posted.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12689631
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 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