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

Wierd Record Set Problem...

Status
Not open for further replies.

cawi17

IS-IT--Management
Oct 25, 2002
18
0
0
MY

Below are the codes for my .asp page.... It's kindda weird... I've tried to display multiple recordsets values usin rs("") on different places on a page... but it dispaly only 1 of the rs("")

The rs("Subject") field and rs("Content") field are Memo Data type....

As you can see, I'd tried to retrieve rs("Subject") on 2 location on the page... but when previewing, onyl 1 rs diplay the information. The other is empty... What's wrong with it?....



<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<table width="700" border="1" cellpadding="2" cellspacing="2">
<%

Dim cn
Dim rs
Dim sqlstring

Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")


'viewing forum by category


dataConn= "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("cd2buy.mdb")
cn.open dataConn

sqlstring = "SELECT FORUM.* FROM FORUM WHERE (((FORUM.Forum_ID)=" & Request("threadid") & "))"

rs.Open sqlstring, cn

Response.Write("Subject is :" & rs("Subject"))

Response.Write("<tr><font size=" & chr(34) & "4" & chr(34) &" face="& chr(34) & "Arial, Helvetica, sans-serif"& chr(34) & "><strong>" & rs("Category") & "</strong></font><br><br></tr> ")

Response.Write("<tr> <td width= "& chr(34) & "125" & chr(34) & " rowspan=" & chr(34) & "2" & chr(34) & " align="& chr(34) & "center"& chr(34) &" valign="& chr(34) & "middle"& chr(34) & " bgcolor=" & chr(34) & "#9999FF" & chr(34) & "> <font color="& chr(34) & "#FFFFFF" & chr(34) & " size="& chr(34) & "2"& chr(34) &" face="& chr(34) & "Arial, Helvetica, sans-serif"& chr(34) & "><strong>by : " & rs("UserName") & "</strong></font><font size="& chr(34) & "2"& chr(34) &" face="& chr(34) &"Arial, Helvetica, sans-serif"& chr(34) & "><br><br><font color="& chr(34) & "#FFFFFF"& chr(34) &"><strong>Date:</strong> " & rs("Date") & "</font><br><font color="& chr(34) & "#FFFFFF" & chr(34) & "><strong>Time:</strong> " & rs("Time") & "</font></font></td><td width="& chr(34) & "559"& chr(34) & " height="& chr(34) & "39"& chr(34) & "><font color="& chr(34) & "#CCCC33" & chr(34) & "><strong><em><u>Subject : " & rs("Subject") & "</strong></font></u></em></td></tr><tr><td bgcolor=" & chr(34) & "#CCCCFF" & chr(34) & "><font size="& chr(34) & "2" & chr(34) & " face=" & chr(34) & "Geneva, Arial, Helvetica, sans-serif"& chr(34) & ">" & rs("Content") & "</font></td></tr>")
Response.Write("This is the subject :" & rs("Forum_ID"))






' reply thread form

%>
</table>

<table width="500" border="0">
<tr>
<td bgcolor="#CCCCFF">

<br>
&nbsp;&nbsp;<font size="4" face="Arial, Helvetica, sans-serif"><strong>Reply
To Thread</strong></font>
<form action="processreply.asp" method="post" name="replyforum">
<table width="500" border="0">
<tr>
<td width="100">&nbsp;&nbsp;<font size="2" face="Arial, Helvetica, sans-serif">Subject
: </font> </td>
<td width="574"><input name="theSubject" type="text" id="theSubject3" size="66" <% Response.Write(" value=" & chr(34) & rs("Subject")) & chr(34) %>>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;<font size="2" face="Arial, Helvetica, sans-serif">Category
:</font></td>


<td><input type="text" name="theCategory" <% Response.Write(" value=" & chr(34) & rs("Category")) & chr(34) %>></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><% Response.Write("<textarea name="& chr(34) & "thecontent"& chr(34) &" cols=50 rows=10 >" & rs("Content")& "</textarea>")%></td>
</tr>
</table>


<p align="center">
<input type="submit" name="Submit" value="Reply Thread !">
&nbsp;
<input type="reset" name="Submit2" value="Reset">
<input type="hidden" name="parentthread" value="1">
</p>
</form>



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




</body>
</html>
 
couple of things when getting memo fields use a fieldlist indtead of * and assign the memo field value to a variable and display that instead.

and for goodness sake split up that mass of concatenated strings into several .write lines to make it simpler to read and debug.

Code:
with response
.Write "<tr>"
.write "<td width= '125'rowspan='2' "
.write "align='center'>"
.write variable
.write "</td>

' rest of code 


end with
will work exactly the same and make it much easier to read



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thank You again ChrisHirst,

you saved me twice...

And for the 'With' thing, okay i'll use it from now on("perhaps after i finish the page").....

I even tried to assign the rs("Subject") and rs("Content") each into a variable before displaying them.... It worked okay!...


Thanks again.....

:)
 
Another tip: if you don't want all of your fields returned (using *), perhaps because it would return way too much data or something, just list your memo fields last in your field list. Bizarre that the order makes a difference, but it does, and you can safely refer to it as rs("myMemoField") or what have you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top