nested loops

HI all.

First time here so thanks in advance.

I have a .asp page which is displaying the software we have and which
computers this software is installed on.

The code below works fine but i want to put a nested loop in so it
only displays one instance of the software and then lists all the
computers which has it installed and then loop on to the next software
etc etc etc.

Please can someone help as i don't know how to add this additional
loop.

code:

<% set dbConn = server.createobject("adodb.connection")
dbConn.open
"Provider=****;Server=****;UID=intranetlogin;PWD=*****;Datab ase=******"

Set rsEquipmentList = Server.CreateObject("ADODB.Recordset")
Set rsSoftwareList = Server.CreateObject("ADODB.Recordset")


sql = ""

sql3 = "SELECT mbSoftware.id, mbSoftware.fldDeveloper,
mbSoftware.fldProduct, mbSoftware.fldVersion,
mbSoftwareInstallation.fldhardware, equipment.inventorynumber,
equipment.description, equipment.pcname FROM (mbSoftware INNER JOIN
mbSoftwareInstallation ON mbSoftware.id =
mbSoftwareInstallation.fldsoftware) INNER JOIN equipment ON
mbSoftwareInstallation.fldhardware = equipment.inventorynumber ORDER
BY mbSoftware.fldDeveloper, mbSoftware.fldProduct,
mbSoftware.fldVersion, equipment.inventorynumber"

rsEquipmentList.open sql, dbConn, 3, 3

rsSoftwareList.open sql3, dbConn, 3, 3
%>

<html>
<head>
<title>IT Software Licensing</title>
<link href="/includes/intranet.css" rel="stylesheet" type="text/
css">

<style type="text/css" media="screen">

#maindiv
{
width:750px;
}

</style>
<style type="text/css" media="print">

#maindiv
{
width:100%;
}

</style>



<center>
<div id=maindiv>
<table width=100% cellpadding="0" cellspacing="0" border="1"
align="center">
<tr><td>
<!-- #include virtual="/includes/headermb.asp" -->
</td></tr>


<tr>
<td align="center" bgcolor="#9ba8d0">
<br>
<table width="95%" bgcolor="#efefef" cellpadding="5" cellspacing="0"
border="1">
<tr>
<td><span class="title1"><img src="/images/icons/
mouse.png"><small><small> Software Licensing</small></small></span></
td>
</tr>
<tr>
<td>
<!-- #include file="navbar.inc" -->
</td></tr>
</table>
<br>
<table width="95%" bgcolor="#efefef" cellpadding="5"
cellspacing="0" border="1">
<tr>
<td class="normalsize">
<table width="100%" bgcolor="#efefef" cellpadding="5"
cellspacing="0" border="1">
<tr class="normalsize"><td><b>Software</b></
td><td><b>Computer</b></td></tr>

<% Do While Not rsSoftwareList.EOF %>
<tr class="normalsize"><td valign="top"><% =
rsSoftwareList.Fields("fldDeveloper") & " " &
rsSoftwareList.Fields("fldProduct") & " " &
rsSoftwareList.Fields("fldVersion") %></td><td valign="top">


<li><% = rssoftwareList.Fields("inventorynumber") & " - " &
rssoftwareList.Fields("description") & " - " &
rssoftwareList.Fields("pcname") %>






</td></tr>



<% rsSoftwareList.MoveNext %><% Loop %>
</table>
<br>
</td>
</tr>
</table>

<br>

</td>
</table>
</div>
</center>
</body>
</html>


I have a feeling i need to add an extra sql statement to "sql = """
and use rsequipmentlist as the second loop but i don't know how to
link the two sql statements

Any help will be gratefully accepted.

Thanks

Pigsy101
pigsy101 [ Mo, 02 Juli 2007 11:14 ] [ ID #1757564 ]

Re: nested loops

"pigsy101" <pacrawford101 [at] fsmail.net> wrote in message
news:1183367652.596946.89210 [at] k29g2000hsd.googlegroups.com...
> HI all.
>
> First time here so thanks in advance.
>
> I have a .asp page which is displaying the software we have and which
> computers this software is installed on.
>
> The code below works fine but i want to put a nested loop in so it
> only displays one instance of the software and then lists all the
> computers which has it installed and then loop on to the next software
> etc etc etc.
>
> Please can someone help as i don't know how to add this additional
> loop.
>
> code:
>
> <% set dbConn = server.createobject("adodb.connection")
> dbConn.open
> "Provider=****;Server=****;UID=intranetlogin;PWD=*****;Datab ase=******"
>
> Set rsEquipmentList = Server.CreateObject("ADODB.Recordset")
> Set rsSoftwareList = Server.CreateObject("ADODB.Recordset")
>
>
> sql = ""
>
> sql3 = "SELECT mbSoftware.id, mbSoftware.fldDeveloper,
> mbSoftware.fldProduct, mbSoftware.fldVersion,
> mbSoftwareInstallation.fldhardware, equipment.inventorynumber,
> equipment.description, equipment.pcname FROM (mbSoftware INNER JOIN
> mbSoftwareInstallation ON mbSoftware.id =
> mbSoftwareInstallation.fldsoftware) INNER JOIN equipment ON
> mbSoftwareInstallation.fldhardware = equipment.inventorynumber ORDER
> BY mbSoftware.fldDeveloper, mbSoftware.fldProduct,
> mbSoftware.fldVersion, equipment.inventorynumber"
>
> rsEquipmentList.open sql, dbConn, 3, 3
>
> rsSoftwareList.open sql3, dbConn, 3, 3
> %>
>
> <html>
> <head>
> <title>IT Software Licensing</title>
> <link href="/includes/intranet.css" rel="stylesheet" type="text/
> css">
>
> <style type="text/css" media="screen">
>
> #maindiv
> {
> width:750px;
> }
>
> </style>
> <style type="text/css" media="print">
>
> #maindiv
> {
> width:100%;
> }
>
> </style>
>
>
>
> <center>
> <div id=maindiv>
> <table width=100% cellpadding="0" cellspacing="0" border="1"
> align="center">
> <tr><td>
> <!-- #include virtual="/includes/headermb.asp" -->
> </td></tr>
>
>
> <tr>
> <td align="center" bgcolor="#9ba8d0">
> <br>
> <table width="95%" bgcolor="#efefef" cellpadding="5" cellspacing="0"
> border="1">
> <tr>
> <td><span class="title1"><img src="/images/icons/
> mouse.png"><small><small> Software Licensing</small></small></span></
> td>
> </tr>
> <tr>
> <td>
> <!-- #include file="navbar.inc" -->
> </td></tr>
> </table>
> <br>
> <table width="95%" bgcolor="#efefef" cellpadding="5"
> cellspacing="0" border="1">
> <tr>
> <td class="normalsize">
> <table width="100%" bgcolor="#efefef" cellpadding="5"
> cellspacing="0" border="1">
> <tr class="normalsize"><td><b>Software</b></
> td><td><b>Computer</b></td></tr>
>
> <% Do While Not rsSoftwareList.EOF %>
> <tr class="normalsize"><td valign="top"><% =
> rsSoftwareList.Fields("fldDeveloper") & " " &
> rsSoftwareList.Fields("fldProduct") & " " &
> rsSoftwareList.Fields("fldVersion") %></td><td valign="top">
>
>
> <li><% = rssoftwareList.Fields("inventorynumber") & " - " &
> rssoftwareList.Fields("description") & " - " &
> rssoftwareList.Fields("pcname") %>
>
>
>
>
>
>
> </td></tr>
>
>
>
> <% rsSoftwareList.MoveNext %><% Loop %>
> </table>
> <br>
> </td>
> </tr>
> </table>
>
> <br>
>
> </td>
> </table>
> </div>
> </center>
> </body>
> </html>
>
>
> I have a feeling i need to add an extra sql statement to "sql = """
> and use rsequipmentlist as the second loop but i don't know how to
> link the two sql statements
>
> Any help will be gratefully accepted.
>

this should help, and will avoid the need fopr nested loops:
Mike Brind [ Di, 03 Juli 2007 15:04 ] [ ID #1758633 ]

Re: nested loops

"pigsy101" <pacrawford101 [at] fsmail.net> wrote in message
news:1183367652.596946.89210 [at] k29g2000hsd.googlegroups.com...
> HI all.
>
> First time here so thanks in advance.
>
> I have a .asp page which is displaying the software we have and which
> computers this software is installed on.
>
> The code below works fine but i want to put a nested loop in so it
> only displays one instance of the software and then lists all the
> computers which has it installed and then loop on to the next software
> etc etc etc.
>
> Please can someone help as i don't know how to add this additional
> loop.
>
> code:
>
> <% set dbConn = server.createobject("adodb.connection")
> dbConn.open
> "Provider=****;Server=****;UID=intranetlogin;PWD=*****;Datab ase=******"
>
> Set rsEquipmentList = Server.CreateObject("ADODB.Recordset")
> Set rsSoftwareList = Server.CreateObject("ADODB.Recordset")
>
>
> sql = ""
>
> sql3 = "SELECT mbSoftware.id, mbSoftware.fldDeveloper,
> mbSoftware.fldProduct, mbSoftware.fldVersion,
> mbSoftwareInstallation.fldhardware, equipment.inventorynumber,
> equipment.description, equipment.pcname FROM (mbSoftware INNER JOIN
> mbSoftwareInstallation ON mbSoftware.id =
> mbSoftwareInstallation.fldsoftware) INNER JOIN equipment ON
> mbSoftwareInstallation.fldhardware = equipment.inventorynumber ORDER
> BY mbSoftware.fldDeveloper, mbSoftware.fldProduct,
> mbSoftware.fldVersion, equipment.inventorynumber"
>
> rsEquipmentList.open sql, dbConn, 3, 3
>
> rsSoftwareList.open sql3, dbConn, 3, 3
> %>
>
> <html>
> <head>
> <title>IT Software Licensing</title>
> <link href="/includes/intranet.css" rel="stylesheet" type="text/
> css">
>
> <style type="text/css" media="screen">
>
> #maindiv
> {
> width:750px;
> }
>
> </style>
> <style type="text/css" media="print">
>
> #maindiv
> {
> width:100%;
> }
>
> </style>
>
>
>
> <center>
> <div id=maindiv>
> <table width=100% cellpadding="0" cellspacing="0" border="1"
> align="center">
> <tr><td>
> <!-- #include virtual="/includes/headermb.asp" -->
> </td></tr>
>
>
> <tr>
> <td align="center" bgcolor="#9ba8d0">
> <br>
> <table width="95%" bgcolor="#efefef" cellpadding="5" cellspacing="0"
> border="1">
> <tr>
> <td><span class="title1"><img src="/images/icons/
> mouse.png"><small><small> Software Licensing</small></small></span></
> td>
> </tr>
> <tr>
> <td>
> <!-- #include file="navbar.inc" -->
> </td></tr>
> </table>
> <br>
> <table width="95%" bgcolor="#efefef" cellpadding="5"
> cellspacing="0" border="1">
> <tr>
> <td class="normalsize">
> <table width="100%" bgcolor="#efefef" cellpadding="5"
> cellspacing="0" border="1">
> <tr class="normalsize"><td><b>Software</b></
> td><td><b>Computer</b></td></tr>
>
> <% Do While Not rsSoftwareList.EOF %>
> <tr class="normalsize"><td valign="top"><% =
> rsSoftwareList.Fields("fldDeveloper") & " " &
> rsSoftwareList.Fields("fldProduct") & " " &
> rsSoftwareList.Fields("fldVersion") %></td><td valign="top">
>
>
> <li><% = rssoftwareList.Fields("inventorynumber") & " - " &
> rssoftwareList.Fields("description") & " - " &
> rssoftwareList.Fields("pcname") %>
>
>
>
>
>
>
> </td></tr>
>
>
>
> <% rsSoftwareList.MoveNext %><% Loop %>
> </table>
> <br>
> </td>
> </tr>
> </table>
>
> <br>
>
> </td>
> </table>
> </div>
> </center>
> </body>
> </html>
>
>
> I have a feeling i need to add an extra sql statement to "sql = """
> and use rsequipmentlist as the second loop but i don't know how to
> link the two sql statements
>
> Any help will be gratefully accepted.
>

Opps - hit return for a line feed, and the damn thing sent itself!

Here's the link:
http://databases.aspfaq.com/database/how-do-i-present-one-to -many-relationships-in-my-asp-page.html
Mike Brind [ Di, 03 Juli 2007 15:06 ] [ ID #1758634 ]
Webserver » microsoft.public.inetserver.asp.general » nested loops

Vorheriges Thema: No data returned.
Nächstes Thema: Ajax within ASP