Saving HTML formatted text in a database

I am building a website similar to Craigslist. I would like to know how to save text in html format (bold / italic / font size etc.) in sql 2008 database?

In word order, the user enters their text, formats it with font size, bold, etc. and saves information. What is the most efficient way to store this in a database?

+3
source share
6 answers

Save it in the nvarchar (max) field. Make sure you use parameterized queries for security. Read http://www.aspnet101.com/2007/03/parameterized-queries-in-asp-net/

+4

, HTML, - script.

, <script> <style>. script, ! .

+3

, , nvarchar (max)

+2

, NVARCHAR () XML.

, xml - .

+1

, , NVARCHAR (MAX).

, .

+1

I would put it in the nvarchar (MAX) field if you are using SQL Server 2008 or higher otherwise. If you are using SQL Server 2005 or lower, and if the character count is below 2000, you can use the nvarchar (2000) type. If this limits the use of the text type too much.

0
source

Source: https://habr.com/ru/post/1745969/


All Articles