Re: can i preserve newlines in ASP/Access?
- From: "Mike Brind" <paxtonend@xxxxxxxxxxx>
- Date: 1 Oct 2006 10:20:15 -0700
Bob Barrows [MVP] wrote:
SLH wrote:
i have a form on an ASP page that when submitted writes the data fromI cannot reproduce this. Here is my code. What are you doing differently?
a text area to an access DB memo field.
the problem im having is this:
if someone enters:
Dear someone,
im writing this to tel you blah blah
sincerely,
me
if i later pull this from the DB to display on a page, the formatting
is lost. i think the newlines are being truncated completely because
the output looks like this:
Dear someone,im writing this... etc.
is there a way to preserve the formatting?
<%
dim cn,cmd,sql,ar, s, rs
sql="Insert INTO MYTABLE(ID,memofield) VALUES(?,?)"
if Request.Form.Count>0 then
ar=array(10,Request.Form("txtMemo"))
set cn=CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & server.MapPath("db7.mdb")
set cmd=CreateObject("ADODB.Command")
cmd.CommandText=sql
cmd.CommandType=1 'adCmdText
set cmd.ActiveConnection=cn
on error resume next
cmd.Execute ,ar,128 'adExecuteNoRecords
if err<>0 then
Response.Write "Error upon insert:<BR>" & _
Err.Description
Else
s=""
sql = "select memofield from mytable where id=10"
Err.Clear
set rs=cn.Execute(sql,,1)
if err<>0 then
Response.Write "Error upon retrieval:<BR>" & _
Err.Description
Else
if not rs.eof then s="Data from db" & vbcrlf & rs(0)
end if
end if
rs.close:set rs=nothing
set cmd=nothing
cn.Close:set cn=nothing
end if
%>
<HTML>
<BODY>
<FORM action="" method=POST id=form1 name=form1>
<TEXTAREA rows=6 cols=20 id=textarea1 name=txtMemo>
<%=s%>
</TEXTAREA>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
</BODY>
</HTML>
He's not writing *to* a textarea - he's taking text submitted to a
database via a textarea in a form and trying to display it as html. As
I said, I gave him the answer to this under one of his other aliases.
--
Mike Brind
.
- Follow-Ups:
- Re: can i preserve newlines in ASP/Access?
- From: Bob Barrows [MVP]
- Re: can i preserve newlines in ASP/Access?
- References:
- Re: can i preserve newlines in ASP/Access?
- From: Bob Barrows [MVP]
- Re: can i preserve newlines in ASP/Access?
- Prev by Date: Re: can i preserve newlines in ASP/Access?
- Next by Date: Re: can i preserve newlines in ASP/Access?
- Previous by thread: Re: can i preserve newlines in ASP/Access?
- Next by thread: Re: can i preserve newlines in ASP/Access?
- Index(es):
Relevant Pages
|
Loading