Print Page | Close Window

Retriving Data frm DB via 2 sql statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10697
Printed Date: 31 March 2026 at 3:06pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Retriving Data frm DB via 2 sql statement
Posted By: ifeyinwa
Subject: Retriving Data frm DB via 2 sql statement
Date Posted: 01 June 2004 at 4:16pm

Hope you all are  alive and well cause I will need you to come to my rescue once again.
appreciate this as Always.
I am  working with asp with an Access DB back end.

The code below worked well until I added this second select statement;
{SELECT area FROM tblopgaCOm2 WHERE billNo = '" &
 Request.Form("BILLNO") " }
this select statement should display its data in the text area called
otherdescription.But no data is being displayed.
All the other data that is displayed on the form are displayed from the 1st SQL
Statement which works okay.
 
Is it possible to look at my script & tell me if I am missing out anything from this script.A precise response will be greatly appreciated.Thank you.

<%
Test = request.querystring("Test")    
StrbillNo = Trim(Request.form("billNo"))
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

SQLQuery1= "SELECT area FROM tblopgaCOm2 WHERE billNo =

'"&Request.Form("billNO")&"' " 
Rs1.Open SQLQuery1, Conn,1,1
%>

<form method="POST" action="legconfirm.asp" >         
     <td width="20%" bgcolor="#99CCFF" height="36">&nbsp;<b><font        

size="2">ID#:
        </font> </b><input type="text" name="Test" style="background-color:

#D2D2D2"  size="9" value="<%=RS("Test")%>" readonly></td>
      <td width="43%" bgcolor="#99CCFF" height="36">&nbsp;<b><font

size="2">BILL</font>#</b>
        <input type="text" name="billNo" style="background-color: #D2D2D2" 

size="9" value="<%=RS("billNo")%>" readonly></td>
      <td width="10%" bgcolor="#99CCFF" height="36">&nbsp;&nbsp;&nbsp;

<input type="text" name="rdr3rd" style="background-color: #D2D2D2" 

size="13" value="<% if RS("rdr3rd")= "Y"  Then
  Response.write("3rd Reader")
Else
 Response.write("")

End if%>"  readonly  </td>
      <td width="23%" bgcolor="#99CCFF" height="36"><font

size="2"><b>PRIORCOMMENTS:</b></font>&l t;/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="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">
     
      <%While Not Rs1.EOF%>
        <%
        Dim desc
        desc=desc & Rs1("area")&","
        %>
       <%
          Rs1.MoveNext
        Wend
      %>

    <textarea rows="2" name="otherdescription" cols="20"> 
       
    <%=desc%></textarea></td>
       <tr>
      <td width="23%" bgcolor="#99CCFF" height="36"><b><font

size="2">COMMENTS:</font></b></td>
      <td width="239%" bgcolor="#E6E3E4" height="36" colspan="4"><textarea

rows="6" name="comments" cols ="50"><%=RS("comments")%></textarea>
      <td width="52%" height="36">&nbsp;</td>
         <tr>
      <td width="23%" bgcolor="#99CCFF" height="36"><input type="submit"

value="Submit" name="B1"><input type="reset" value="Reset"

name="B2"></td>
    




Replies:
Posted By: Semikolon
Date Posted: 03 June 2004 at 12:46pm
are you sure there are anything in the field?


Posted By: ifeyinwa
Date Posted: 03 June 2004 at 2:41pm

yes there are values in the  field.

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>&l t;/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>




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net