Solved

asp saving text area into db

Posted on 2004-04-13
5
240 Views
Last Modified: 2012-05-04
Hello,

when I have the text from a textarea into a db I lose all the spaces on it, who can I save/retrieve and display in html using asp all the spaces?

thanks.
0
Comment
Question by:alain123
  • 3
5 Comments
 
LVL 12

Expert Comment

by:GoofyDawg
ID: 10819818
What database are you using? Normally, spaces are preserved unless you have some explicit filtering function that removes the spaces.
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 250 total points
ID: 10819823
A simple example here:

in your form, add:

<textarea name="aboutus" cols="50" rows="8"></textarea>

then in your process page:

<%
      response.expires = 0
      response.expiresabsolute = Now() - 1
      response.addHeader "pragma","no-cache"
      response.addHeader "cache-control","private"
      Response.CacheControl = "no-cache"

      on error goto 0
      
      set conn=server.CreateObject("adodb.connection")
      conn.Open "Provider=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("db.mdb")
      
      aboutus = Replace(Replace(Request("aboutus"),"'","''"), VbCrlf, "<br>")
      
      set rs = Server.CreateObject("ADODB.Recordset")
      SQLStr = "Update Setting Set " & _
                   "aboutus = '" & aboutus & "' "
      conn.execute SQLStr
      
      Conn.Close
      Set Rs = Nothing
      Set Conn = Nothing
%>

To display in HTML, you may need to display it like:

<%=Replace("" & Rs("aboutus"),"<br>",VbCrlf)%>

(in the case you know how to establish a connection using ADO)

Hope this helps
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10819835
>>when I have the text from a textarea into a db I lose all the spaces on it
Just curious if you entering your data with spaces like " " , if it's you may lose all your space when displayed in HTML, as HTML nature treats empty spaces as Empty , like below both are same when displayed in HTML:

Hello World<br>
Hello    World<br>

So the only way to 'retain' the spaces is using &nbsp; to replace the spaces.

so, you can try like:

aboutus = Replace(Replace(Replace(Request("aboutus"),"'","''"), VbCrlf, "<br>")," ","&nbsp;")

or

aboutus = Replace(Replace(Request("aboutus"),"'","''")," ","&nbsp;")

that's depends on your requirement..

regards

0
 
LVL 1

Author Comment

by:alain123
ID: 10820030
thank you!
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 10820162
You're welcome, glad could make helps ;-) cheers
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pass url parameter as session 9 52
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 113
If-Then-Else ASP problem 6 59
ASP/VB email question 4 30
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now