nested loops

nested loops

am 02.07.2007 11:14:12 von pigsy101

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
%>



IT Software Licensing









align="center">










border="1">




Software Licensing td>





cellspacing="0" border="1">




cellspacing="0" border="1">


<% Do While Not rsSoftwareList.EOF %>




<% rsSoftwareList.MoveNext %><% Loop %>
Software td>Computer
<% =
rsSoftwareList.Fields("fldDeveloper") & " " &
rsSoftwareList.Fields("fldProduct") & " " &
rsSoftwareList.Fields("fldVersion") %>



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





















  • 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

    Re: nested loops

    am 03.07.2007 15:04:11 von Mike Brind

    "pigsy101" wrote in message
    news:1183367652.596946.89210@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
    > %>
    >
    >
    >
    > IT Software Licensing
    >
    >
    >
    >
    >
    >
    >
    >


    >

    > > align="center">
    >
    >
    >
    >
    >
    >

    >
    >

    >

    > > border="1">
    >
    >
    >
    >
    >
    Software Licensing > td>
    >

    >
    >

    >

    > > cellspacing="0" border="1">
    >
    >
    >
    >

    > > cellspacing="0" border="1">
    >
    >
    > <% Do While Not rsSoftwareList.EOF %>
    >
    >
    >
    >
    > <% rsSoftwareList.MoveNext %><% Loop %>
    >
    Software > td>Computer
    <% =
    > rsSoftwareList.Fields("fldDeveloper") & " " &
    > rsSoftwareList.Fields("fldProduct") & " " &
    > rsSoftwareList.Fields("fldVersion") %>

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

  • >

    >

    >
    >

    >
    >

    >

    >

    >
    >
    >
    >
    > 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:

    Re: nested loops

    am 03.07.2007 15:06:08 von Mike Brind

    "pigsy101" wrote in message
    news:1183367652.596946.89210@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
    > %>
    >
    >
    >
    > IT Software Licensing
    >
    >
    >
    >
    >
    >
    >
    >


    >

    > > align="center">
    >
    >
    >
    >
    >
    >

    >
    >

    >

    > > border="1">
    >
    >
    >
    >
    >
    Software Licensing > td>
    >

    >
    >

    >

    > > cellspacing="0" border="1">
    >
    >
    >
    >

    > > cellspacing="0" border="1">
    >
    >
    > <% Do While Not rsSoftwareList.EOF %>
    >
    >
    >
    >
    > <% rsSoftwareList.MoveNext %><% Loop %>
    >
    Software > td>Computer
    <% =
    > rsSoftwareList.Fields("fldDeveloper") & " " &
    > rsSoftwareList.Fields("fldProduct") & " " &
    > rsSoftwareList.Fields("fldVersion") %>

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

  • >

    >

    >
    >

    >
    >

    >

    >

    >
    >
    >
    >
    > 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