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

textarea to display database memo field

Status
Not open for further replies.

junglist666

Technical User
Mar 9, 2006
25
GB
im tryin to get my text area to display the contents of a record of a data type memo field.

i can successfully display the contents of a text field in a form input text box like so..

<input class="addtxtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("address") %>">



but when i try to display the contents of my 'shortdesc' field (memo datatype) then it displays nothin in the textarea.. anyone know why?

<textarea class="area" rows="4" name="shortdesc" cols="40" value="<% = rsProperty("shortdesc") %>"></textarea>
 
can you show us your sql query...

make sure that field shortdesc is selected last in the select items list...i mean

Select field1, field2, blah,shortdesc from mytable

next...look into GetChunk() method...

-DNG
 
Yep

It's a known bug in ASP. You need to cast the memo field to a variable immediately after getting from the recordset, then use the variable to display the field.

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
ok, well if i show you my code maybe u could show me how to declare that memo field to another variable so it can be used in my textarea.

i am loading several fields into this form but if you just pay attention to the short desc textarea

Code:
<%
Dim adoCon
Dim rsProperty
Dim strSQL
Dim lngRecordNo

lngRecordNo = CLng(Request.QueryString("ID"))

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("properties.mdb")
Set rsProperty = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM properties WHERE id=" & lngRecordNo
rsProperty.Open strSQL, adoCon
%>

<form name="form" method="post" action="update_entry.asp">
<p class="main3">3. Rent (p.c.m):</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("rent") %>">  
  <br>
    <p class="main3">5. Address:</p>
  <input class="addtxtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("address") %>">  
<br>
<p class="main3">6. Short Description:</p><textarea class="area" rows="4" name="shortdesc" cols="40" value="<% = rsProperty("shortdesc") %>"></textarea><br>
<p class="main3">7. Long Description:</p><textarea class="area" rows=7 name="longdesc" cols="40" value="<% = rsProperty("longdesc") %>"></textarea><br>

  <p class="main3">8. Small Preview Image:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("small") %>">  
  <p class="main3">9. Outer Image 1:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("out1") %>"> 
  <br>
  <p class="main3">10. Outer Image 2:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("out2") %>"> 
  <br>
<p class="main3">11. Inner Image 1:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in1") %>"> 
  <br>
  <p class="main3">12.Inner Image 2:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in2") %>"> 
  <br>
  <p class="main3">13. Inner Image 3:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in3") %>"> 
  <br>
  <p class="main3">14. Inner Image 4:</p>
  <input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in4") %>"> 
  <br>
  <input type="hidden" name="id" value="<% = rsProperty("id") %>">
  <input class="red2" type="submit" name="Submit" value="Submit">
</form>

this form is populated by my user selecting a property from another page.. and the above form loads that record using the ID.

like i said, the text field--->input text box works so i know the right record is being displayed.
 
ok im trying to fill my textarea with details from a memo field.. i have read up on it and i realise that memo fields cause trouble but im gonna try it anyway.. i believe i have to assign the memo field to another variable in my asp code and then use that variable as the display for the text area so here is what i am trying.. if someone could help me i would be most grateful..

<%
Dim adoCon
Dim rsProperty
Dim strSQL
Dim lngRecordNo

lngRecordNo = CLng(Request.QueryString("ID"))

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("properties.mdb")
Set rsProperty = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM properties WHERE id=" & lngRecordNo
rsProperty.Open strSQL, adoCon
if NOT rsProperty.EOF then
Dim strMemoField
strMemoField = rsProperty("shortdesc")
end if
%>


and im trying to display it with this..

<textarea rows="4" name="shortdesc" cols="40" value="<% strMemoField %>"></textarea>


now this is being displayed in my textarea

<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a000d'</font>
<p>
<font face="Arial" size=2>Type mismatch</font>
<p>
<font face="Arial" size=2>/falconwood/update_property.asp</font><font face="Arial" size=2>, line 83</font>

and the error is on this line..


<p class="main3">6. Short Description:</p><textarea class="area" rows="4" name="shortdesc" cols="40" value="<% strMemoField %>"></textarea>


please someone help me... please

here is the full code for reference.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
<html>
<head>
<title>Falconwood Estates | Residential Lettings | Property Management - Property Listings</title>
<link rel="stylesheet" type="text/css" href="style.css">

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onLoad="MM_preloadImages('studio2.jpg','1bed2.jpg','2bed2.jpg','3bed2.jpg','other2.jpg')">
<div id="wrap">

<div id="second">
</div>

<div id="third">
<img class="map" src="map.jpg" hspace="0"/>
<img class="logo" src="logo.jpg"/>
</div>
<div id="fourth">
</div>

<div id="bleft">
<a href="add_property.asp"><img class="profile" src="menuaddprop.jpg"/></a>
<a href="edit_property.asp"><img class="history" src="menueditprop.jpg"/></a>
<a href="delete_property.asp"><img class="property" src="menudelprop.jpg"/></a>
<a href="view_property.asp"><img class="contact" src="menuviewprop.jpg"/></a>
</div>

<div id="bright">
<br><br>
<img class="title" src="edprop.jpg"/>
<%
Dim adoCon
Dim rsProperty
Dim strSQL
Dim lngRecordNo

lngRecordNo = CLng(Request.QueryString("ID"))

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("properties.mdb")
Set rsProperty = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM properties WHERE id=" & lngRecordNo
rsProperty.Open strSQL, adoCon
if NOT rsProperty.EOF then
Dim strMemoField
strMemoField = rsProperty("shortdesc")
end if
%>
<form name="form" method="post" action="update_entry.asp">
<p class="main3">3. Rent (p.c.m):</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("rent") %>">
<br>
<p class="main3">5. Address:</p>
<input class="addtxtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("address") %>">
<br>
<p class="main3">6. Short Description:</p><textarea class="area" rows="4" name="shortdesc" cols="40" value="<% strMemoField %>"></textarea><br>
<p class="main3">7. Long Description:</p><textarea class="area" rows=7 name="longdesc" cols="40" value="<% = rsProperty("longdesc") %>"></textarea><br>

<p class="main3">8. Small Preview Image:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("small") %>">
<p class="main3">9. Outer Image 1:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("out1") %>">
<br>
<p class="main3">10. Outer Image 2:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("out2") %>">
<br>
<p class="main3">11. Inner Image 1:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in1") %>">
<br>
<p class="main3">12.Inner Image 2:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in2") %>">
<br>
<p class="main3">13. Inner Image 3:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in3") %>">
<br>
<p class="main3">14. Inner Image 4:</p>
<input class="txtbox" type="text" name="type" maxlength="20" value="<% = rsProperty("in4") %>">
<br>
<input type="hidden" name="id" value="<% = rsProperty("id") %>">
<input class="red2" type="submit" name="Submit" value="Submit">
</form>
<br><br>
</div>

</div>
</body>

</html>

<%
rsProperty.Close
Set rsProperty = Nothing
Set adoCon = Nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top