Hello all,
I am opening 2 connections to different databases , then saying show records in a table where a field from one databsae table = the field from another database table.
however,
It loops through the first recordset showing all school names, but it doesn't loop through the second recordset to show related filenames.
It just shows the first filename next to every school.
this is my code, can anybody see what I am doing wrong ?
<%
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
module = Server.HTMLEncode(rscompany.Fields("dfee".Value)
Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
%>
<%
Set conn = Server.CreateObject("ADODB.Connection"
conn.open "Holding","edholding","edholding"
Set Session("Holding_conn" = conn
%>
<%
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
Response.Write "No Files Uploaded."
else
%>
<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>
<%
do while Not rscompany.eof
%>
<%
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%>
<%
rscompany.MoveNext
loop%>
</TBODY>
<TFOOT></TFOOT>
</TABLE>
</BODY>
<% RS.Close
Conn.Close
set RS = Nothing
set Conn = Nothing
%>
<%
RScompany.Close
MyConncompany.Close
Set RScompany = Nothing
Set MyConncompany = Nothing
%>
<br>
<%end if%>
thank you in advance.
Jamie
I am opening 2 connections to different databases , then saying show records in a table where a field from one databsae table = the field from another database table.
however,
It loops through the first recordset showing all school names, but it doesn't loop through the second recordset to show related filenames.
It just shows the first filename next to every school.
this is my code, can anybody see what I am doing wrong ?
<%
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
module = Server.HTMLEncode(rscompany.Fields("dfee".Value)
Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
%>
<%
Set conn = Server.CreateObject("ADODB.Connection"
conn.open "Holding","edholding","edholding"
Set Session("Holding_conn" = conn
%>
<%
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
Response.Write "No Files Uploaded."
else
%>
<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>
<%
do while Not rscompany.eof
%>
<%
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%>
<%
rscompany.MoveNext
loop%>
</TBODY>
<TFOOT></TFOOT>
</TABLE>
</BODY>
<% RS.Close
Conn.Close
set RS = Nothing
set Conn = Nothing
%>
<%
RScompany.Close
MyConncompany.Close
Set RScompany = Nothing
Set MyConncompany = Nothing
%>
<br>
<%end if%>
thank you in advance.
Jamie