//接收一个长度大于8000的字符串
string a=textBox1.Text;(textbox1输入一个字符数量超过8000字符串)
// 插入一张表里
sqlcommand cmd1= new sqlcommand("insert into table1(content) values(@content)",this.conn.dbconn);
cmd1.Parameters.Add("@content", a)运行时报错
赋予 类型 'varchar' 的大小(8050)超过了任意数据类型的最大允许值(8000)。必须声明变量 '@content'但我的content字段在sql server 里定义的是ntext型(ntext型的容量为最大2的30次方),而c#中的string型的储存长度也应该是大于8000呀,不知是怎么回事,请大虾们帮帮忙(语法大家不用研究,没有问题,我这里只是写个大概的意思)
string a=textBox1.Text;(textbox1输入一个字符数量超过8000字符串)
// 插入一张表里
sqlcommand cmd1= new sqlcommand("insert into table1(content) values(@content)",this.conn.dbconn);
cmd1.Parameters.Add("@content", a)运行时报错
赋予 类型 'varchar' 的大小(8050)超过了任意数据类型的最大允许值(8000)。必须声明变量 '@content'但我的content字段在sql server 里定义的是ntext型(ntext型的容量为最大2的30次方),而c#中的string型的储存长度也应该是大于8000呀,不知是怎么回事,请大虾们帮帮忙(语法大家不用研究,没有问题,我这里只是写个大概的意思)
解决方案 »
- c#实现一秒钟从串口接收到的数据取一个绘制成一段时间的实时动态的显示
- 未在本地计算机上注册 Microsoft.ACE.OLEDB.12.0 提供程序.
- Ms Enterprice Library 微软的企业库有知道的吗?相关资料贴一下。
- 关于C#打开WORD时出现的奇怪问题
- 使用webpart时出现错误,未解决!!
- 有关winform中获得窗体大小的问题
- 关于环境配置
- 【新人求助】关于C#网络共享
- 初学MVC 有问题想问
- 使用 C#+ASP.NET+SQLServer 建设的网站 www.chinadeer.com/index.aspx测试中!
- 调查:有没有做小灵通短信开发的,集合啦!
- c#如何把Int32型加在Bytes数组前在netstream里发送出去?
加上数据类型才行:
SqlDbType.NText
SqlParameter parameter = new SqlParameter("@Description");
parameter.SqlDbType=SqlDbType.NText;
parameter.IsNullable = true;
parameter.Value = paramValue;cmd.Parameters.Add(parameter);
cmd1.Parameters.Add("@content", a) 这样的写法不对的吧?
例如:
SqlParameter parameter = new SqlParameter("@Description");
parameter.SqlDbType=SqlDbType.NText;
parameter.IsNullable = true;
parameter.Value = paramValue;cmd.Parameters.Add(parameter);
有没有简便一些的写法呢
比如说
cmd1.Parameters.Add(sqlDbType.NText("@content"), a)行不?
command1.Parameters.Add("@1", 1);
command1.Parameters.Add("@2", 2);
command1.Parameters.Add("@3", 3);
command1.Parameters.Add("@4", 4);
command1.Parameters.Add("@5", 5);
......
能不能直接在add方法的时候加入数据类型,
param.Value = "Beverages";
但再次读取后还是修改前的值,这是怎么回事呀
为什么要给NText类型的数据500个长度!!!???对于这个类型不设置长度的.
SqlCommand command1 = new SqlCommand("update JF_Category set CategoryName=@CategoryName,FileExt=@FileExt,CategorySet=@CategorySet,CategoryIndexTemplet=@CategoryIndexTemplet,CategorySubPageTemplet=@CategorySubPageTemplet,NewsTemplet=@NewsTemplet,CategoryDir=@CategoryDir,CategoryDomain=@CategoryDomain,PageSize=@PageSize,CategoryNavigation=@CategoryNavigation,NewsNavigation=@NewsNavigation,AutoUpdate=@AutoUpdate where CategoryID=@CategoryID", this.conn.dbconn);
command1.Parameters.Add("@CategoryName", this.g_CategoryName);
command1.Parameters.Add("@FileExt", this.g_FileExt);
command1.Parameters.Add("@CategorySet", this.CategorySet);
command1.Parameters.Add("@CategoryIndexTemplet",this.g_CategoryIndexTemplet);
command1.Parameters.Add("@CategorySubPageTemplet",SqlDbType.NText,16,this.g_CategorySubPageTemplet);
command1.Parameters.Add("@NewsTemplet", this.g_NewsTemplet);
command1.Parameters.Add("@CategoryDir", this.g_CategoryDir);
command1.Parameters.Add("@CategoryDomain", this.g_CategoryDomain);
command1.Parameters.Add("@PageSize", this.g_PageSize);
command1.Parameters.Add("@CategoryNavigation", this.g_CategoryNavigation);
command1.Parameters.Add("@NewsNavigation", this.g_NewsNavigation);
command1.Parameters.Add("@AutoUpdate", this.g_AutoUpdate);
command1.Parameters.Add("@CategoryID", this.CategoryID);
这是整个的语句
改了@CategorySubPageTemplet后,系统报错:
被准备语句 '(@CategoryName nvarchar(100),@FileExt nvarchar(500),@CategorySet' 需要参数 @CategoryName,但未提供该参数。
怎么回事呀