Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Retriving data Using 2 sql statements...

Reply
Thread Tools

Retriving data Using 2 sql statements...

 
 
iffy agbim
Guest
Posts: n/a
 
      06-03-2004


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!
 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      06-03-2004
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
>
>
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing through XSL and Retriving data sp XML 1 02-07-2006 01:05 PM
retriving data from memo data type of msaccess to asp.net Aneesh a ASP .Net Web Services 0 05-07-2005 01:11 AM
Storing and Retriving any document in SQL Server 2000 using ASP.Net Manish Naik ASP .Net 2 06-30-2004 03:49 AM
Retriving data simon ASP .Net 0 11-26-2003 02:15 PM
adding and retriving data from the machine.config? george d lake ASP .Net 0 08-29-2003 09:00 PM



Advertisments