Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot perform a nested loop

Status
Not open for further replies.

QuintonV

Technical User
Jul 3, 2001
37
ZA
Hi

I have a table whith 2 recordsets one recordset displays an event name a date a maximum participants, this has a smal where cluase select those fiew fields where the startdate is >= to date() this works fine. the second recordset(participants) is a diffrent table it has 3 fields primary key an event_id which is the primary key for the events table and a member_id which is the primary key for the member. All I want to do is repeat the first recordset and then include the total from recordset2 particicapants where the event_id = recordset1("id") when I insert this it sort of works fine i dont get any vb script errors anymore.But unfortunately it repeats my first recordset correctly but the total from recordset which is included in the same row with recordset1 always shows the total for the first event, its not requerying itself.

Please can anyone help me out.

Quinton
 
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;../Connections/events.asp&quot; -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = &quot;2002/05/05&quot;
if (date() <> &quot;&quot;) then Recordset1__MMColParam = date()
%>
<!--#include file=&quot;../Connections/events.asp&quot; -->
<%
set Recordset1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset1.ActiveConnection = MM_events_STRING
Recordset1.Source = &quot;SELECT agegroup, eventname, ID, maxgamers, startdate FROM eventdetails WHERE startdate >= #&quot; + Replace(Recordset1__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;# ORDER BY startdate ASC&quot;
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = &quot;2&quot;
if (Recordset1(&quot;id&quot;) <> &quot;&quot;) then Recordset2__MMColParam = Recordset1(&quot;id&quot;)
%>
<%
set Recordset2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset2.ActiveConnection = MM_events_STRING
Recordset2.Source = &quot;SELECT * FROM participants WHERE event_id = &quot; + Replace(Recordset2__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 3
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 10
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
Recordset2_total = Recordset2.RecordCount

' set the number of rows displayed on this page
If (Recordset2_numRows < 0) Then
Recordset2_numRows = Recordset2_total
Elseif (Recordset2_numRows = 0) Then
Recordset2_numRows = 1
End If

' set the first and last displayed record
Recordset2_first = 1
Recordset2_last = Recordset2_first + Recordset2_numRows - 1

' if we have the correct record count, check the other stats
If (Recordset2_total <> -1) Then
If (Recordset2_first > Recordset2_total) Then Recordset2_first = Recordset2_total
If (Recordset2_last > Recordset2_total) Then Recordset2_last = Recordset2_total
If (Recordset2_numRows > Recordset2_total) Then Recordset2_numRows = Recordset2_total
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (Recordset2_total = -1) Then

' count the total records by iterating through the recordset
Recordset2_total=0
While (Not Recordset2.EOF)
Recordset2_total = Recordset2_total + 1
Recordset2.MoveNext
Wend

' reset the cursor to the beginning
If (Recordset2.CursorType > 0) Then
Recordset2.MoveFirst
Else
Recordset2.Requery
End If

' set the number of rows displayed on this page
If (Recordset2_numRows < 0 Or Recordset2_numRows > Recordset2_total) Then
Recordset2_numRows = Recordset2_total
End If

' set the first and last displayed record
Recordset2_first = 1
Recordset2_last = Recordset2_first + Recordset2_numRows - 1
If (Recordset2_first > Recordset2_total) Then Recordset2_first = Recordset2_total
If (Recordset2_last > Recordset2_total) Then Recordset2_last = Recordset2_total

End If
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = &quot;&index=&quot;
If (MM_paramName <> &quot;&quot;) Then MM_removeList = MM_removeList & &quot;&&quot; & MM_paramName & &quot;=&quot;
MM_keepURL=&quot;&quot;:MM_keepForm=&quot;&quot;:MM_keepBoth=&quot;&quot;:MM_keepNone=&quot;&quot;

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = &quot;&&quot; & Item & &quot;=&quot;
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = &quot;&&quot; & Item & &quot;=&quot;
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> &quot;&quot;) Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> &quot;&quot;) Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> &quot;&quot;) Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> &quot;&quot;) Then
MM_joinChar = &quot;&&quot;
Else
MM_joinChar = &quot;&quot;
End If
End Function
%>
<script language=&quot;JavaScript&quot;>
<!--

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf(&quot;?&quot;))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script language=&quot;JavaScript&quot;>
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
//-->
</script>
<body bgcolor=&quot;#4B4B4B&quot; onLoad=&quot;MM_preloadImages('../Images/btg.jpg')&quot;>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<table width=&quot;98%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;20&quot; height=&quot;36&quot; background=&quot;../Images/sidetl.jpg&quot;>&nbsp;</td>
<td background=&quot;../Images/sidet.jpg&quot; height=&quot;36&quot;>&nbsp;</td>
<td width=&quot;20&quot; height=&quot;36&quot; background=&quot;../Images/sidetr.jpg&quot;>&nbsp;</td>
</tr>
<tr>
<td background=&quot;../Images/sidel.jpg&quot; width=&quot;20&quot;>&nbsp;</td>
<td bgcolor=&quot;#000000&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;1&quot;>
<tr>
<td bgcolor=&quot;#202020&quot;><b><font color=&quot;#FF7F00&quot; size=&quot;2&quot; face=&quot;Times New Roman, Times, serif&quot;>Event
name</font></b></td>
<td bgcolor=&quot;#202020&quot;><b><font color=&quot;#FF7F00&quot; size=&quot;2&quot; face=&quot;Times New Roman, Times, serif&quot;>Start
time</font></b></td>
<td bgcolor=&quot;#202020&quot;><b><font color=&quot;#FF7F00&quot; size=&quot;2&quot; face=&quot;Times New Roman, Times, serif&quot;>Max
participants </font></b></td>
<td bgcolor=&quot;#202020&quot;><b><font color=&quot;#FF7F00&quot; size=&quot;2&quot; face=&quot;Times New Roman, Times, serif&quot;>Age
group</font></b></td>
<td width=&quot;30&quot; bgcolor=&quot;#202020&quot;><font color=&quot;#FF7F00&quot; face=&quot;Times New Roman, Times, serif&quot; size=&quot;2&quot;><b>Vie</b></font><font face=&quot;Times New Roman, Times, serif&quot; size=&quot;2&quot;><b><font color=&quot;#FF7F00&quot;>w</font></b></font></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td bgcolor=&quot;#464646&quot; height=&quot;25&quot;>
<font color=&quot;#FFFFFF&quot; face=&quot;Times New Roman, Times, serif&quot; size=&quot;1&quot;><b><%=(Recordset1.Fields.Item(&quot;eventname&quot;).Value)%> </b></font></td>
<td bgcolor=&quot;#464646&quot; height=&quot;25&quot;><font color=&quot;#FFFFFF&quot; face=&quot;Times New Roman, Times, serif&quot; size=&quot;2&quot;><b><font size=&quot;1&quot;><%=(Recordset1.Fields.Item(&quot;startdate&quot;).Value)%></font></b></font></td>
<td bgcolor=&quot;#464646&quot; height=&quot;25&quot;><b><font color=&quot;#FFFFFF&quot; face=&quot;Times New Roman, Times, serif&quot; size=&quot;1&quot;><%=(Recordset2_total)%>/ <%=(Recordset1.Fields.Item(&quot;maxgamers&quot;).Value)%> </font></b></td>
<td bgcolor=&quot;#464646&quot; height=&quot;25&quot;><b><font color=&quot;#FFFFFF&quot; face=&quot;Times New Roman, Times, serif&quot; size=&quot;1&quot;><%=(Recordset1.Fields.Item(&quot;agegroup&quot;).Value)%></font></b></td>
<td width=&quot;30&quot; height=&quot;25&quot;><a href=&quot;event_view.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & &quot;ID=&quot; & Recordset1.Fields.Item(&quot;ID&quot;).Value %>&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image2','','../Images/btg.jpg',1)&quot;><img src=&quot;../Images/btb.jpg&quot; name=&quot;Image2&quot; width=&quot;25&quot; height=&quot;25&quot; border=&quot;0&quot; usemap=&quot;#button&quot;></a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</td>
<td background=&quot;../Images/sider.jpg&quot; width=&quot;20&quot;>&nbsp;</td>
</tr>
<tr>
<td width=&quot;20&quot; height=&quot;36&quot; background=&quot;../Images/sidebl.jpg&quot;>&nbsp;</td>
<td background=&quot;../Images/sideb.jpg&quot; height=&quot;36&quot;>&nbsp;</td>
<td width=&quot;20&quot; height=&quot;36&quot; background=&quot;../Images/sidebr.jpg&quot;>&nbsp;</td>
</tr>
</table>
<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
<% If Recordset1.EOF And Recordset1.BOF Then %>
<table width=&quot;250&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot; bordercolor=&quot;#CC0000&quot; bgcolor=&quot;#CCCCCC&quot;>
<tr>
<td bgcolor=&quot;#FF7F00&quot;>
<div align=&quot;center&quot;><font color=&quot;#CC0000&quot;><b><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; color=&quot;#CCCCCC&quot;>There
Are Currently No Events Listed Please Try Again Later </font></b></font></div>
</td>
</tr>
</table>
<% End If ' end Recordset1.EOF And Recordset1.BOF %>
<p align=&quot;center&quot;>&nbsp;</p>
<%
Recordset1.Close()
%>
<%
Recordset2.Close()
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top