Retriving data Using 2 sql statements...

I

iffy agbim

I am getting just one value returned in the textarea called
otherdescription based on the 2nd sql statement in my code .


The values returned from the field in the DB called area should be 2
values and not one value .can anyone tell me what I am missing out .
Is it that it is not looping well or what????.The first sql displays
all the infor required into the form based on the billNo selected. that
works okay

<%
Test = request.querystring("Test")
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Set Rs1 = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "Select * from tblopgaCOm2 WHERE Test = " & Test
RS.Open SQLQuery ,Conn,1,1

strBillNo=RS("billNo")

SQLQuery1= "Select area FROM tblopgaCOm2 WHERE billNo = " & strBillNo
&"' "
RS1.Open SQLQuery ,Conn,1,1

%>
<form method="POST" action="legconfirm.asp" >
<td width="23%" bgcolor="#99CCFF" height="36"><font
size="2"><b>PRIORCOMMENTS:</b></font></td>
<td width="239%" bgcolor="#C0C0C0" height="36"
colspan="4"><textarea rows="8" name="priorcomments" readonly
style="background-color: #D2D2D2"
cols="50"><%=RS("priorcomments")%></textarea>
<p>&nbsp;</td>
<td width="52%" height="36">&nbsp;</td>
<tr>
<td width="23%" bgcolor="#99CCFF" height="36"><font
size="2"><b>OTHER
DESCRIPTION</b></font><b><font size="2">:</font></b></td>
<td width="239%" bgcolor="#E6E3E4" height="36" colspan="4">
<textarea rows="4" name="otherdescription" cols="20">
<%While Not Rs1.EOF
Response.Write(Rs1("area") & ", ")
Rs1.MoveNext
Wend
%>
</textarea></td>


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Aaron [SQL Server MVP]

Why are you doing this in two select statements?

<%
Test = request.querystring("Test")
Set Conn = CreateObject("ADODB.Connection")
Conn.Open "eiwp"
' stop using DSNs!
' please see http://www.aspfaq.com/2126

' "Select * from tblopgaCOm2 WHERE Test = " & Test
' do not use SELECT *!
' please see http://www.aspfaq.com/2096

SQLQuery = "SELECT priorcomments, area " & _
" FROM tblopgaCOm2 " & _
" WHERE Test = " & Test
' I assume Test is a numeric?

set rs = conn.execute(SQLQuery)
priorcomments = Server.HTMLEncode(rs(0))
area = Server.HTMLEncode(rs(1))
response.write "<textarea>" & priorcomments
response.write "</textarea><textarea>"
do while not rs.eof
response.write rs("area") & ", "
rs.movenext
loop
rs.close: set rs = nothing
conn.close: set conn = nothing
%>

You can put the rest of your HTML back in there. For other information, see
http://www.aspfaq.com/2188 (treatment of MEMO/TEXT columns, if that's what
priorcomments and/or area are).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top