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><fo
nt 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><fo
nt 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><fo
nt color="#666666">email</fon
t></strong
></div></t
d>
<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><fo
nt color="#666666">Case #</font></strong></div></t
d>
<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><fo
nt color="#666666">Process</f
ont></stro
ng></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><fo
nt color="#666666">Status</fo
nt></stron
g></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><fo
nt 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><fo
nt 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><fo
nt 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><fo
nt 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><fo
nt color="#666666">Comments</
font></str
ong></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="../../../Image
s/menus/se
paratortop
.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=RecordCounte
r + 1
If RecordCounter Mod 2 = 1 Then
Response.Write("bgcolor=#F
BFBFB")
End If
%>
bgcolor="#FFFFFF" onMouseOver="this.style.ba
ckgroundCo
lor='#FFFF
CC'" onMouseOut="this.style.bac
kgroundCol
or=''">
<td width="10"> </td>
<td><span class="bodytextreportsc">
<%
' Display repeat region row count - By RobGT -
http://robgt.comvarRobGT_Count = (Repeat1__index + Request("offset") + 1)
Response.Write(varRobGT_Co
unt)
%>
</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("La
stNm").Val
ue)%></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("Fi
rstNm").Va
lue)%></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("em
ail").Valu
e)%></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('
../../Case
s/GeneralI
nfo/Update
casedetail
s.asp?case
id=<%=(Cas
es.Fields.
Item("Id")
.Value)%>'
,'CaseDeta
ils','menu
bar=yes,sc
rollbars=y
es,resizab
le=yes,wid
th=800,hei
ght=600')"
><%=(Cases
.Fields.It
em("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("Pr
ocesscatal
og").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.F
ields.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.I
tem("Filed
on").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.I
tem("Appro
vedon").Va
lue), 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.I
tem("Valid
todate").V
alue), 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.I
tem("NIVMa
xStatus").
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").Va
lue
Comments.Filter = "CaseID=" & FilterParam
While (NOT Comments.EOF)
%>
<img src="../../Images/blankpur
ple.gif" alt="" width="5" height="4"> <%=
(Comments.
Fields.Ite
m("Comment
s").Value)
%>
<%
Comments.MoveNext()
Wend
%>
</span></td>
</tr>
<tr>
<td colspan="25" background="../../../Image
s/menus/se
paratortop
.gif"><img
src="../../../Images/blank
.gif" alt="" width="10" height="3"></td>
</tr>
<%
Repeat1__index=Repeat1__in
dex+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.