Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
197 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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

719 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