If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Formating data from a database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-02, 06:50
pthompson2002 pthompson2002 is offline
Registered User
 
Join Date: Sep 2002
Posts: 3
Formating data from a database

I have a question that I think can be solved using ASp, but I'm not 100% sure so apologies in advance if it can't.

On our website we have a form that, on submission, writes to our database. The form includes a textarea that the user can format how they choose, i.e add carriage returns etc. Obviously when this data is written to the database it is just one big line of text, thats not a problem. However I was wondering if it is possilbe for the data to be re-formatted into the same look as the user saw it when he/she submitted it when they retrieve it form the database.

I was wondering if there was some kind of funciton that would substitute carriage reutrns for other characters, * for example and on retrieval from the database replace the * with a carriage return.

Any help would be much appreciated
Reply With Quote
  #2 (permalink)  
Old 09-30-02, 09:10
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
perhaps you could go and talk to whoever wrote the script that places the form field text into the database, because they can certainly tell you how carriage returns are handled

it sounds like the carriage returns are being stripped out, and if that's the case, you could substitute a different character, and translate it on the way out again, except that you'll have a hard time picking a character that will never ever be entered by a user

besides, the answer to your requirements is not to strip the carriage returns, just store them into the database field

rudy
http://rudy.ca/
Reply With Quote
  #3 (permalink)  
Old 09-30-02, 16:34
dwilliams dwilliams is offline
Registered User
 
Join Date: Sep 2002
Posts: 17
Carriage returns are not stripped by default. We have the same function on our site and have not problems with returning the data exactly as the user entered it.

Is there some sort of special handling of the text that is occuring?
__________________
David Williams
Senior Jack of All Trades
Reply With Quote
  #4 (permalink)  
Old 10-08-02, 05:47
Caveman Caveman is offline
Registered User
 
Join Date: Oct 2002
Posts: 1
Quote:
Originally posted by dwilliams
Carriage returns are not stripped by default. We have the same function on our site and have not problems with returning the data exactly as the user entered it.

Is there some sort of special handling of the text that is occuring?
No, the fact is that the carriage return of the DB is different then the one of the HTML. Use the following function

Replace(Fieldname,chr(13),"<br />").

This replaces the DB carriage returns bij HTML carriage returns.
Reply With Quote
  #5 (permalink)  
Old 10-16-02, 17:30
chickenlover chickenlover is offline
Registered User
 
Join Date: Oct 2002
Posts: 5
There is a quick cheat if you only want to view the text on a web page - simply make the text fields on both pages (the entry page and the view page) the same width in characters e.g. 72.

That way, the text shows it's original structure
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On