Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2004, 09:00 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Forms and Database Entries

When using forms to enter information into a database, what do you have to do to have the info entered exactly as you typed it in the form, such as pagebreaks, carriage returns, and the like.

Currently, if I enter info into a form such as:
Hi world,
I love p2p.wrox.com.
Chris

It enters into the database and when I pull it out for display it comes out as:
Hi world, I love p2p.wrox.com. Chris

I want it to store and return out exactly as I originally entered it.
 
Old June 4th, 2004, 09:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK, before writing the data into the table, replace all VBCRLF with "<br>" in that Form variable. That should produce what you wanted.

Code:
Replace(Request.Form("txtField"),vbCRLF,"<br>")
Cheers!



_________________________
-Vijay G
Strive for Perfection
 
Old June 4th, 2004, 10:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Alternatively, you could use this code when you display the information, instead of when you save it in the database.

By transforming it when you display it, you can keep the data in the database application independent, so it's easier to reuse in other type of applications (export to Word, Excel, for example).

However, doing the transformation when you display the data means a performance hit, as you have to do it every time you retrieve and display the info. If you're really sure you're never going to reuse the information in another application, you could transform the data when you save it; in all other cases I think it's better to do it when you display it.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 4th, 2004, 10:11 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Thanks guys! That's exactly what I was looking for. As far as saving the formatted data, under normal circumstances I won't have to worry about it. There are times that I can see that I may not want to pre-format the data so thanks for bringing that up. Thanks again!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to print out database entries... Teessider_2000 Beginning PHP 0 June 29th, 2007 02:58 PM
Automatic Entries on Forms taraj Access VBA 2 June 16th, 2006 07:37 AM
SQL Database storing entries in GMT Time rijahs SQL Server 2000 1 June 7th, 2006 01:50 PM
Remove entries from listview and database on click neo_jakey Pro VB Databases 1 September 20th, 2004 12:21 PM
Remove entries from listview and database on click neo_jakey VB Databases Basics 2 September 20th, 2004 10:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.