我正在使用使用ajax控件工具包的默认文本编辑器,并且我需要将用户可以粘贴到编辑器中的图像保存到数据库中。在数据库中的列VARBINARY(MAX),但是当我尝试保存我得到以下将图像从Ajax控件工具包编辑器保存到SQL数据库
Implicit conversion from data type nvarchar(max) to varbinary(max) is not allowed. Use the CONVERT function to run this query
我后来转换的内容错误,则在参数定义为字节像这样
var subgrantdesc = Convert.ToByte(grantdescription_editor.Content);
我有这个
var param0 = new SqlParameter();
param0.ParameterName = "@desc";
param0.SqlDbType = System.Data.SqlDbType.VarBinary;
param0.Value = subgrantdesc;
sql.Parameters.Add(param0);
但是我得到的错误:
System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber....
上述错误指向我将转换为Byte
的代码行。 我想知道如何将通过编辑器控件输入的数据(图像和文本)保存到SQL服务器数据库中。我也想知道HTML格式是否会保留。
任何帮助将不胜感激。