Loading

ASP SQL Nested Loop doing the Loop

Nesting the loop, Important thing to note make sure that you use recordset

 

<%@ LANGUAGE=”VBSCRIPT” %>
<% response.cachecontrol = “Public” %>
<%Response.Buffer = False%>

<HTML>
<HEAD>
<TITLE>Title</TITLE>
</HEAD>

<%
Set conn= Server.CreateObject(“ADODB.Connection”)
conn.ConnectionTimeout = Session(“Support_ConnectionTimeout”)
conn.CommandTimeout = Session(“Support_CommandTimeout”)
conn.Open Session(“Support_ConnectionString”), Session(“Support_RuntimeUserName”), Session(“Support_RuntimePassword”)
Set cmdTemp = Server.CreateObject(“ADODB.Command”)
Set rs1 = Server.CreateObject(“ADODB.Recordset”)
cmdTemp.CommandText = “exec sp”
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = conn
rs1.Open cmdTemp, , 0, 1
%>

 

<% If Not rs1.EOF Or Not rs2.BOF Then %>

<body>

………..First Stuff……………

<%dim CurrentContract%>
<%CurrentContract = 0%>

 <% do While NOT adoOpenCalls.EOF %>

  <%CurrentContract = adoOpenCalls(“con_id”).value%>

  …………1st Loop STUFF………
 �
    <%count = 0%>
    <%
    Set rs1= Server.CreateObject(“ADODB.Recordset”)
    cmdTemp.CommandText = “exec sp” & CurrentContract�
    cmdTemp.CommandType = 1
    Set cmdTemp.ActiveConnection = conn
    adoLoopIncidents.Open cmdTemp, , 0, 1  �
    %>

           �
    �
     <%
     Do while not adoLoopIncidents.eof
     count = count + 1
     %>
   �
     …………2nd Loop STUFF………
    �
     <%adoLoopIncidents.movenext%>
     <%loop%>

  ………….Stuff at end of loop………..

  <% adoOpenCalls.movenext %>
  <%loop%>
<%else%>
……..else stuff………
<%end if%>

……..Last Stuff………

<%
adoOpenCalls.Close
Set adoOpenCalls = Nothing
%>

</BODY>
</HTML>

Leave a Reply

Your email address will not be published. Required fields are marked *