日期:2014-05-20  浏览次数:20389 次

做新闻管理系统,请新闻字段用什么类型好?
我用SQL2005,nvarchar(Max)还是varbinary(max)类型,主要是考虑以后要做全文索引,另外,新闻里有可能有动画,图片元素!


以前我的新闻字段body为
varbinary(max)类型。我用强类型的DataSet映射该表,它将此字段变为System.Byte[]类型,然后我在程序中这样调用以存入到数据库
System.Text.Encoding.UTF8.GetBytes(FreeTxtBody.Text);

然后我配置了全文索引的一些字段,用body字段查找时,无法找到,这是什么原因?如何做?请高手赐教!!!!!!!!!

------解决方案--------------------
图片 动画
最好只是 用字段 表示 相对 位置所在
新闻小 nvarchar
大了就只一text了
sql 2005中 有个 更好的选择是 nvarchar(max)
------解决方案--------------------
同上
------解决方案--------------------
text 容量有12亿字节
------解决方案--------------------
nvarchar(max)
------解决方案--------------------
ntext类型最符合了
------解决方案--------------------
ntext吧.用text恐怕编码麻烦.

SQL2005就用nvchar(max)吧.
------解决方案--------------------
一般新闻字段需要显示的内容是有很多的。我一般使用Text类型。然后在类里设置存入字符的大小。
给你看下我添加新闻写的类。设置新闻内容字段字符存入10000
/**
* 添加新闻
*
* */
public bool addNews(News news)
{
newstitle=news.getNewstitle();
newsauthor=news.getNewsAuthor();
newssource=news.getNewsSource();
newseditor=news.getNewsEditor();
newscontent=news.getNewsContent();

sqlstr=SqlApp.addSqlNews+ "values(@newstitle,@newscontent,@newsauthor,@newssource,@newseditor) ";
try
{
DBConnection.OpenConnection();
cmd=DBHandle.creatSqlCommand(sqlstr);
DBHandle.ExecuteDB( "@newstitle ",SqlDbType.VarChar,50,newstitle);
DBHandle.ExecuteDB( "@newscontent ",SqlDbType.Text,10000,newscontent);
DBHandle.ExecuteDB( "@newsauthor ",SqlDbType.VarChar,20,newsauthor);
DBHandle.ExecuteDB( "@newssource ",SqlDbType.VarChar,50,newssource);
DBHandle.ExecuteDB( "@newseditor ",SqlDbType.VarChar,20,newseditor);
DBHandle.ExecuteNonQuery();
DBHandle.Disposed(); //释放
DBConnection.CloseConnection();
return true;
}
catch(Exception e)
{
System.Console.Write(e.Message);
return false;
}
}
------解决方案--------------------
我都用text
------解决方案--------------------
我没有用过2005啊,2003 用 nvarchar