Hello,
earlier I asked for help regarding looping through 2 recordsets, lobstah came up with the following solution, which works, however this way is storing a connection object - an OPEN connection object at that - in a session variable!.
Does anybody have any other ideas ?
how would I run the first sql, put the results into an array, then close that connection, then open the second connection and run the second sql against the results in the array. ?
<%
Dim SearchTextcompany, MyConncompany, SQLcompany, RScompany
Set MyConncompany=Server.CreateObject("ADODB.Connection"
MyConncompany.Open "schoolsasp","schoolsasp","schoolsasp"
SQLcompany = "SELECT EstablishmentID, DfEE, EstablishmentName From Establishments ORDER BY EstablishmentName"
Set RScompany = MyConncompany.Execute(SQLcompany)
%>
<%
Dim module
Dim sError
Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
%>
<center>
<TABLE BORDER=1 BGCOLOR=#ffffff CELLSPACING=1 CELLPADDING=3><FONT FACE="Arial" COLOR=#000000>
<THEAD>
<TR>
<TH BGCOLOR=#008080 BORDERCOLOR=#000000 nowrap><FONT SIZE=2 FACE="Arial" COLOR=white>Establishment</FONT></TH>
<TH BGCOLOR=#008080 BORDERCOLOR=#000000 nowrap><FONT SIZE=2 FACE="Arial" COLOR=white>Filename</FONT></TH>
</TR>
</THEAD>
<TBODY>
<%
Set conn = Server.CreateObject("ADODB.Connection"
conn.open "Holding","edholding","edholding"
Set Session("Holding_conn" = conn
do while Not rscompany.eof
module = Server.HTMLEncode(rscompany.Fields("dfee".Value)
spCommand.Parameters.Append spCommand.CreateParameter ("@module", 200, 1, 50, module)
sql= "files"
sql = "SELECT DISTINCT [RepGenA].[filename] FROM RepGenA WHERE SUBSTRING(RepGenA.filename,4,4) = '"&module&"' "
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql = sql & " And [" & cstr(Param) & "] = " & cstr(Data)
End If
Set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn, 3, 3
if rs.eof then
sError = "No Files Uploaded."
else
SError="" 'clear error
RS.movefirst
do while Not rs.eof
%>
<TR VALIGN=TOP onMouseover="changeto('yellow')"
onMouseout="changeback('white')">
<TD BORDERCOLOR=#c0c0c0 nowrap><FONT SIZE=2 FACE="Arial" COLOR=#000000><a href="./viewschool.asp?Establishment=<%=Server.HTMLEncode(rscompany.Fields("EstablishmentID".Value)%>"><%=Server.HTMLEncode(rscompany.Fields("DfEE".Value)%>, <%=Server.HTMLEncode(rscompany.Fields("establishmentname".Value)%></A><BR></FONT></TD>
<TD BORDERCOLOR=#c0c0c0 nowrap><FONT SIZE=2 FACE="Arial" COLOR=#000000><a href="./moredetails.asp?Filename=<%=Server.HTMLEncode(rs.Fields("filename".Value)%>"><%=Server.HTMLEncode(rs.Fields("filename".Value)%></a><BR></FONT></TD>
</TR>
<%
rs.MoveNext
loop
end if
rs.close
rscompany.MoveNext
loop%>
</TBODY>
<TFOOT></TFOOT>
</TABLE>
</BODY>
<%
conn.close
set RS = Nothing
set Conn = Nothing
%>
<%
RScompany.Close
MyConncompany.Close
Set RScompany = Nothing
Set MyConncompany = Nothing
%>
<br>
earlier I asked for help regarding looping through 2 recordsets, lobstah came up with the following solution, which works, however this way is storing a connection object - an OPEN connection object at that - in a session variable!.
Does anybody have any other ideas ?
how would I run the first sql, put the results into an array, then close that connection, then open the second connection and run the second sql against the results in the array. ?
<%
Dim SearchTextcompany, MyConncompany, SQLcompany, RScompany
Set MyConncompany=Server.CreateObject("ADODB.Connection"
MyConncompany.Open "schoolsasp","schoolsasp","schoolsasp"
SQLcompany = "SELECT EstablishmentID, DfEE, EstablishmentName From Establishments ORDER BY EstablishmentName"
Set RScompany = MyConncompany.Execute(SQLcompany)
%>
<%
Dim module
Dim sError
Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
%>
<center>
<TABLE BORDER=1 BGCOLOR=#ffffff CELLSPACING=1 CELLPADDING=3><FONT FACE="Arial" COLOR=#000000>
<THEAD>
<TR>
<TH BGCOLOR=#008080 BORDERCOLOR=#000000 nowrap><FONT SIZE=2 FACE="Arial" COLOR=white>Establishment</FONT></TH>
<TH BGCOLOR=#008080 BORDERCOLOR=#000000 nowrap><FONT SIZE=2 FACE="Arial" COLOR=white>Filename</FONT></TH>
</TR>
</THEAD>
<TBODY>
<%
Set conn = Server.CreateObject("ADODB.Connection"
conn.open "Holding","edholding","edholding"
Set Session("Holding_conn" = conn
do while Not rscompany.eof
module = Server.HTMLEncode(rscompany.Fields("dfee".Value)
spCommand.Parameters.Append spCommand.CreateParameter ("@module", 200, 1, 50, module)
sql= "files"
sql = "SELECT DISTINCT [RepGenA].[filename] FROM RepGenA WHERE SUBSTRING(RepGenA.filename,4,4) = '"&module&"' "
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql = sql & " And [" & cstr(Param) & "] = " & cstr(Data)
End If
Set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn, 3, 3
if rs.eof then
sError = "No Files Uploaded."
else
SError="" 'clear error
RS.movefirst
do while Not rs.eof
%>
<TR VALIGN=TOP onMouseover="changeto('yellow')"
onMouseout="changeback('white')">
<TD BORDERCOLOR=#c0c0c0 nowrap><FONT SIZE=2 FACE="Arial" COLOR=#000000><a href="./viewschool.asp?Establishment=<%=Server.HTMLEncode(rscompany.Fields("EstablishmentID".Value)%>"><%=Server.HTMLEncode(rscompany.Fields("DfEE".Value)%>, <%=Server.HTMLEncode(rscompany.Fields("establishmentname".Value)%></A><BR></FONT></TD>
<TD BORDERCOLOR=#c0c0c0 nowrap><FONT SIZE=2 FACE="Arial" COLOR=#000000><a href="./moredetails.asp?Filename=<%=Server.HTMLEncode(rs.Fields("filename".Value)%>"><%=Server.HTMLEncode(rs.Fields("filename".Value)%></a><BR></FONT></TD>
</TR>
<%
rs.MoveNext
loop
end if
rs.close
rscompany.MoveNext
loop%>
</TBODY>
<TFOOT></TFOOT>
</TABLE>
</BODY>
<%
conn.close
set RS = Nothing
set Conn = Nothing
%>
<%
RScompany.Close
MyConncompany.Close
Set RScompany = Nothing
Set MyConncompany = Nothing
%>
<br>