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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 tables in ASP and only 1 displays

Status
Not open for further replies.

Mary10k

IS-IT--Management
Nov 8, 2001
103
US
Hello,
I have written 2 sql statements in my code below and only one table displays on the page. If I comment out one sql statement, the other works, but they will not work together. Could you please point me in the direction of a solution?
Thank you

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<!--#include file="connect.inc"-->
<body>
<P>testing why this won't make a new table</P>
<table>
<tr>
<%

Set recordSet=Server.CreateObject("ADODB.Recordset")
recordSet.Open "SELECT DISTINCT DB_Name FROM DB_Administration WHERE DB_Name is Not Null", GetConnection
Response.Write ("<table border=1><tr bgcolor=#CCCCCC><th>Database Name</th></tr>")
Do While Not recordSet.EOF
Response.Write "<tr><td>" & recordSet("DB_Name") &"<br></td>"

recordSet.MoveNext
Loop
Response.End
%>
<br>
<P>testing why this won't make a new table</P>
</table>

<table>
<tr>
<%
Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open "SELECT DISTINCT Source FROM Meta_Data", GetConnection
Response.Write ("<table border=1><tr bgcolor=#CCCCCC><th>Database Name</th></tr>")
Do While Not RS.EOF
Response.Write "<tr><td>" & RS("Source") &"<br></td>"
RS.MoveNext
Loop
Response.End
%>

</tr></td>
</table>


/body>
</html>
 
take out both Response.End lines. This tells the server to stop sending any more info to the browser.


Tony
_______________________________________________________________
 
Thank you. This did the trick. Do I need to close the record set somehow?
 
yes - after each Loop you need to have:
Code:
recordset.Close
Set recordset = Nothing
Code:
RS.Close
Set RS = Nothing



Tony
_______________________________________________________________
 
also noticed this.
Code:
Response.Write "<tr><td>" & RS("Source") &"<br></td>"
should be
Code:
Response.Write "<tr><td>" & RS("Source") &"</td></tr>"
You dont need the <br> but you do need to close the table row before you create a new one.

Do this for the table code in both your loops.

Tony
_______________________________________________________________
 
Is it necessary to create 2 connections to the server? Why not close the first recordset RS.Close and then start the other sql statement then RS.Close/Set RS = Nothing

Looks as though you're simply querying 2 different tables and if related you could use 1 sql statement w/ a join statement


BSL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top