简体   繁体   中英

Correct way of storing custom text wrapped with styles - Database or Text File?

I am running ASP.NET connecting to a SQL Server 2005 database.

Currently all my data get's saved in the database but when I use my HTML editor control (to allow the user to add styles to the text) sometimes I get the following error when I copy text with lots of styles from another website into the text area (error comes up when data is trying to save to database):

String or binary data would be truncated. The statement has been terminated.

Why is this and how do I handle this? Save the text rather to a text file?

The size of the field in the database is big enough!

Edits

INSERT INTO TableName(Name, Age, Comments) VALUES (@Name, @Age, @Comments)

Then from my code behind I simply call my SQLDatasource like so

SqlDataSource.Insert()

It sounds like you are passing a string variable to a stored procedure whit pe varchar(250) and the string length is over 251, even if the field in the table is varchar(1025) you'll get the error because of the param length is not ok.

Or... Try to use "text" type on db field?

It's an idea, if you get more info we'll be more usefull. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM