我存储了新闻数据(如500字) [英] I have store a news data(like 500 words)

查看:57
本文介绍了我存储了新闻数据(如500字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储的数据只是包含许多单词的新闻。什么应该是列的类型或我如何做到这一点?

store a data that is only words like a news that contains many word. what should be the type of column or how i can do this?

推荐答案

尝试 VARCHAR(MAX) [ ^ ]


创建表时,必须定义足够长的列长度,以存储要插入的数据。似乎您要插入的列仅限于128个字符。



要更改表中的列长度,您可以使用 ALTER TABLE [ ^ ]命令。如下所示:

When you create the table you have to define a column length that is long enough to store the data you're going to insert. Seems that the column you're trying to insert into is limited to 128 characters only.

To change the column length in the table you can use ALTER TABLE[^] command. So something like:
ALTER TABLE MyTableName ALTER COLUMN MyColumnName nvarchar(MAX);


String sql = "INSERT INTO News ( Category,Matter,Subject,date ) VALUES  (@Category,@Matter,@Subject,@date)";
       SqlCommand cmd = new SqlCommand(sql, con);
       cmd.Parameters.Add("@Subject", SqlDbType.VarChar, 100).Value = txtsub.Text;
       cmd.Parameters.Add("@Matter", SqlDbType.VarChar, 8192).Value = txtnews.Text;
       cmd.Parameters.AddWithValue("@Category", dropdwncate.SelectedValue);


这篇关于我存储了新闻数据(如500字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆