Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp saving text area into db

Posted on 2004-04-13
5
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

Accepted Solution

by:
Ryan Chong earned 1000 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 53

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 53

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

704 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