Retriving data Using 2 sql statements...

Discussion in 'ASP General' started by iffy agbim, Jun 3, 2004.

  1. iffy agbim

    iffy agbim Guest

    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!
     
    iffy agbim, Jun 3, 2004
    #1
    1. Advertising

  2. 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).

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "iffy agbim" <> wrote in message
    news:#...
    >
    >
    > 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!
     
    Aaron [SQL Server MVP], Jun 3, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. george d lake
    Replies:
    0
    Views:
    489
    george d lake
    Aug 29, 2003
  2. simon

    Retriving data

    simon, Nov 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    368
    simon
    Nov 26, 2003
  3. Manish Naik
    Replies:
    2
    Views:
    6,715
    Manish Naik
    Jun 30, 2004
  4. sp
    Replies:
    1
    Views:
    432
    Joe Kesselman
    Feb 7, 2006
  5. Aneesh a

    retriving data from memo data type of msaccess to asp.net

    Aneesh a, May 7, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    111
    Aneesh a
    May 7, 2005
Loading...

Share This Page