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
194 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 3 hours left to enroll

630 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