I have an ASP/VB script page that displays the results of a query (repeated region). Inside that region I am using some ASP code to display what would be a 'nested region', which are records from another recordset (one or more) that are related to the main table, problem is that the file that it creates is so big takes forever and crashes IE. I want to see if this can be done with an sql query instead.
The main query is attached, and so is the second query, below is the code that displays the results. As you can see the ASP code goes through ALL of the second table records and see which ones are matched (linked in a relation) with the first one, then goes to the next record, second table has thousands of records so it takes forever, I need to join the two somehow and display those multiple records in just ONE field of the database instead of multiple ones.
--- code is here ---
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<thead><tr >
<td bgcolor="eceef4"><img src="../../../Images/blank.gif" alt="" width="10" height="25"></td>
<td width="19" bgcolor="eceef4"><div align="center"><font color="#666666"><strong>#</strong></font></div></td>
<td valign="middle" bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Last Name</font></strong></div></td>
<td bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">First Name</font></strong></div></td>
<td bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">email</font></strong></div></td>
<td bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Case #</font></strong></div></td>
<td bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Process</font></strong></div></td>
<td bgcolor="eceef4"><table width="8" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="1" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Status</font></strong></div></td>
<td bgcolor="eceef4"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Filing date</font></strong></div></td>
<td bgcolor="eceef4"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Approval date</font></strong></div></td>
<td bgcolor="eceef4"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td bgcolor="eceef4"><div align="center"><strong><font color="#666666">Expiration date</font></strong></div></td>
<td bgcolor="eceef4"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="61" bgcolor="eceef4"><div align="center"><strong><font color="#666666">Status Max date</font></strong></div></td>
<td width="12" bgcolor="eceef4"><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="141" bgcolor="eceef4"><div align="center"><strong><font color="#666666">Comments</font></strong></div></td>
</tr>
<tr>
<td colspan="25"><img src="../../../Images/blank.gif" alt="" width="10" height="10"><img src="../../../Images/blank.gif" alt="" height="6"></td>
</tr>
<tr>
<td colspan="25" background="../../../Images/menus/separatortop.gif"><img src="../../../Images/blank.gif" alt="" width="10" height="3"></td>
</tr>
<tbody>
<%
Dim RecordCounter
RecordCounter = 0
Dim FlushCOunter
FlushCounter = 0
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT Cases.EOF))
%>
<tr <%
RecordCounter=RecordCounter + 1
If RecordCounter Mod 2 = 1 Then
Response.Write("bgcolor=#FBFBFB")
End If
%>
bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#FFFFCC'" onMouseOut="this.style.backgroundColor=''">
<td width="10"> </td>
<td><span class="bodytextreportsc">
<%
' Display repeat region row count - By RobGT - http://robgt.com
varRobGT_Count = (Repeat1__index + Request("offset") + 1)
Response.Write(varRobGT_Count)
%>
</span></td>
<td width="12" valign="middle"><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="80" class="bodytextreports" ><%=(Cases.Fields.Item("LastNm").Value)%></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="83" class="bodytextreports" ><%=(Cases.Fields.Item("FirstNm").Value)%></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="104" class="bodytextreports" ><%=(Cases.Fields.Item("email").Value)%></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="112" class="bodytextreports" ><a href="javascript:;" onClick="MM_openBrWindow('../../Cases/GeneralInfo/Updatecasedetails.asp?caseid=<%=(Cases.Fields.Item("Id").Value)%>','CaseDetails','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600')"><%=(Cases.Fields.Item("CaseId").Value)%></a></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="163" class="bodytextreports" ><%=(Cases.Fields.Item("Processcatalog").Value)%></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="52" class="bodytextreports" ><div align="center"><span class="bodytextreportsC"><%=(Cases.Fields.Item("Nistatus").Value)%></span></div></td>
<td width="12" class="bodytextreports" ><table width="9" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="2" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="69" class="bodytextreports" ><div align="center"><span class="bodytextreportsC"><%= DoDateTime((Cases.Fields.Item("Filedon").Value), 2, 9225) %></span></div></td>
<td width="12" class="bodytextreports" ><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="82" class="bodytextreports" ><div align="center"><span class="bodytextreportsC"><%= DoDateTime((Cases.Fields.Item("Approvedon").Value), 2, 9225) %></span></div></td>
<td width="12" class="bodytextreports" ><table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table></td>
<td width="95" class="bodytextreports" ><div align="center"><span class="bodytextreportsC"><%= DoDateTime((Cases.Fields.Item("Validtodate").Value), 2, 9225) %></span></div></td>
<td width="12"><div align="center">
<table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="10" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table>
</div></td>
<td width="61" ><div align="center"><span class="bodytextreportsC"><%= DoDateTime((Cases.Fields.Item("NIVMaxStatus").Value), 2, 9225) %></span></div></td>
<td ><div align="center">
<table width="12" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="4"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
<td width="4" height="14"><img src="../../../Images/menus/separator.gif" alt="" /></td>
<td width="10"><img src="../../../Images/blank.gif" alt="" width="4" height="25" /></td>
</tr>
</table>
</div></td>
<td width="141" ><span class="bodytextreports">
<%
FilterParam = Cases.Fields.Item("Id").Value
Comments.Filter = "CaseID=" & FilterParam
While (NOT Comments.EOF)
%>
<img src="../../Images/blankpurple.gif" alt="" width="5" height="4"> <%=(Comments.Fields.Item("Comments").Value)%>
<%
Comments.MoveNext()
Wend
%>
</span></td>
</tr>
<tr>
<td colspan="25" background="../../../Images/menus/separatortop.gif"><img src="../../../Images/blank.gif" alt="" width="10" height="3"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
FlushCounter = FlushCounter + 1
If FlushCounter = 250 Then
Response.Flush
FlushCounter = 0
End If
Cases.MoveNext()
Wend
%>
</table>
"Comments" is the field that repeats itself within the result. Please let me know if there are any other questions.
Table # 1 Name: Cases
ID of table # 1 = id
Table # 2 Casecomments:
id of table # 2 that links it to number 1 = caseid
So if I was to simply join them would be:
casecomments.caseid = cases.id
The thing with the join is that I get multiple records of the same 'case' (first table), one for each comment (using left join), I need to somehow display all this comments in just one field, maybe separated by a " - " or something of that sort.
Hope I explained myself.
by: amucinobluedotPosted on 2009-10-02 at 07:37:21ID: 25478318
This is the code that loops the second recordset with the first one:
lue ple.gif" alt="" width="5" height="4"> <%=(C omments.Fi elds.Item( "Comments" ).Value)%>
<%
FilterParam = Cases.Fields.Item("Id").Va
Comments.Filter = "CaseID=" & FilterParam
While (NOT Comments.EOF)
%>
<img src="../../Images/blankpur
<%
Comments.MoveNext()
Wend
%>