How to save a paragraph in a database?

I am creating a website that includes a user posting comments. Now I want to save different comments. I read a little about Linq to SQL and ADO .. they all talk about storing small bits of information like names, emails, passwords, etc. But what is the most efficient way to save messages (which will be included on the page, for example, on youtube) at the end?

+4
source share
5 answers

I think the comments on the webpage are still considered "small bits". Just make sure there is enough space in the database field ( nvarchar(MAX) if supported, otherwise text or ntext , depending on the selected database)

I do not think that you need to start considering other methods of accessing data if you do not have tens of kilobytes of data for one object or a very large number of objects on a page.

+6
source

Similar. You also want html to encode your message before embedding it in the database, to avoid unwanted sql injections. Linq does not have such problems since it uses options to insert your text.

You should prefer to enter text with text on top of the built-in sql + encoding.

+1
source

At intervals, you would use the legacy Text type, but it will be removed in the next version, so it is recommended to use varchar (max) .

+1
source

There is a text data type in the MSSQL database. You can use it for comments. Then in the program this is just an ordinary line.

Edit: since text will be deprecated, just use varchar(max) as others say.

0
source

You can also use the ntext data type. I use this for text.

0
source

All Articles