简体   繁体   English

存储用样式包装的自定义文本的正确方法-数据库还是文本文件?

[英]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. 我正在运行连接到SQL Server 2005数据库的ASP.NET。

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): 目前,我所有的数据都保存在数据库中,但是当我使用HTML编辑器控件(允许用户向文本中添加样式)时,当我将具有很多样式的文本从另一个网站复制到文本区域时,有时会出现以下错误(当数据试图保存到数据库时出现错误):

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

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. 听起来好像您正在将字符串变量传递给varchar(250)的存储过程,并且字符串长度超过251,即使表中的字段为varchar(1025),由于参数长度,您也会收到错误消息不好。

Or... Try to use "text" type on db field? 还是...尝试在数据库字段上使用“文本”类型?

It's an idea, if you get more info we'll be more usefull. 这是一个主意,如果您获得更多信息,我们将更加有用。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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