Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ASP forms to Populate SQL

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
CA
Hi,

I would like to post articles on my website. I created an SQL table called Articles (all fields are char strings)

ArticleID, ArticleTitle, ArticleDetail, ArticleDate.

Since the detail portion can be really long, I used the maximum size for that field (7600). When i populate my form field with article detail info, it saves it to the database.

WHen displaying the info (pulling from SQL onto ASP page) all the line breaks, formatting is removed. I would like to maintain the formatting and line breaks. Any ideas?

What would be the appropriate field type for something like this?

Thanks
 
try...
Code:
Replace(objRecordset(&quot;Fieldname&quot;),vbcrlf,&quot;<BR>&quot;)
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
You said the fields are char strings.
If you set the field to a really large amount (7600) then that many bytes are set aside for EACH record.
You can use a varchar which only uses the amount necessary up to the amount used, but what if someone types something longer than 7600?

The text field may seem small (16) but that's actually only holding a pointer to the &quot;real&quot; data, which can be any length!!
 
Hector..

If im picturing this correctly, you say I can have the text field at 16 which points to the real data. Where do you recommend the real data reside (I didn't want to have static data on each page and then call the page when needed). I currently have it residing in an SQL table column.



 
Sorry, I mustn't have been clear.
A text field takes as much or as little space as necessary.

So you have a table like this......

ID int identity
theData text 16


The field called theData could contain &quot;hi there&quot; or it could contain the contents of a novel.

SQL stores the information on pages, and a text field and an image field can use as many as necessary.

 
Ok i'm a little confused..(excuse please)

I didn't know that a text field set for 16 can hold the contents of a novel! (any size) If so thats what I will change the field type to (its currently set for char).

How can I display a text field in ASP? i noticed everytime I have a text field in my table, I can never get anything to display, all the other columns do. I guess I would like some direction as to what the Articles table should be setup as. I currently have it setup as:

ArticleID, ArticleTitle, ArticleDetail, ArticleDate.
num(10) char(20) char(7500) char(15)


I already ran into the problem of
1) reaching the max 7500 for the table
2) having articles larger then 7500

Thanks for your help!
 
In SQL server those 16 bytes hold a pointer to the REAL data.
You insert your &quot;novel&quot;, and SQL stores it on as many pages, as necessary.

So your insert statement would be like.....

INSERT INTO tblWhatever (ArticleID, ArticleTitle,ArticleDetail,ArticleDate)
VALUES (100,'The title of the article','blah blah blah blah etc. as long as necessary', '01/01/2001')

also, I'd change that articledate to a smalldatetime

If you take a look at BOL, I believe there's a description of how the text field works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top