| Author |
Topic |
|
prpball
Starting Member
19 Posts |
Posted - 2008-12-31 : 13:52:39
|
| Can SQL Server 2005 retain formatted text?If so, does anyone know how to send the formatted text to SQL?I am using asp.net and want to insert text that is formatted in that textbox into sql and be able to bring it back as it was put in.For example, line breaks, font bolding, size, etc. |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2008-12-31 : 14:34:44
|
| ntext datatype in SQL Server will store Html markupTry storing your html in an ntext field (column). Then retrieve it onto your webpage to see the results.r&r |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-12-31 : 14:38:42
|
| From Books On linentext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. For more information, see Using Large-Value Data Types.Jim |
 |
|
|
prpball
Starting Member
19 Posts |
Posted - 2008-12-31 : 14:48:18
|
| Thanks, I am currently using nvarchar(200).The users that will be inputting the text do not know html markup.Is there another way of doing this? |
 |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2008-12-31 : 15:47:50
|
| Well the users of your form won't be required to know html markup.Once they type something into the textbox it is up to the code behind the textbox to handle the submission. A textbox is a asp.net form control isn't it? You as the coder would handle the data in the textbox once it is submitted across the web server and eventually to the sql server. You define what styling to use (ie.. font color, bold text etc..).How is the formatting applied? Does the user have a handful of buttons they can press which inserts html for them (like on this forum?) |
 |
|
|
prpball
Starting Member
19 Posts |
Posted - 2008-12-31 : 15:55:17
|
| No buttons.When they hit the return button they get a new line.How do I know when they have used a return button in code and when I submit that to sql it takes it as a one long string. I need to be able to pull that text back out of sql in the same format it was submitted in.For example,NameAddressCity, State ZipI need the above to go into sql with the breaks and come back out with those same line breaks.Does that help? |
 |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2008-12-31 : 16:37:25
|
| Well here is the short answer..A newline gets appended to the users data on every press of the return key inside your asp.net textbox form control.To use your example..Name,\n OR possibly Name,\r\nCity,\n OR possibly City, \r\nYou would need to detect this with your asp code before inserting into the database. You then need to replace those values with <br> so the string will become Name,<br>City,<br>.This is presuming that you display the data in html and are not using asp.net calls to print the data. |
 |
|
|
prpball
Starting Member
19 Posts |
Posted - 2009-01-05 : 11:25:19
|
| I would be reading the information from SQL by using a datasource and outputting the information into a datalist templated column. When I read the information from sql how would I now keep the formatting. |
 |
|
|
|