日期:2014-05-18  浏览次数:22027 次

操作数数据类型 text 对于 count 运算符无效。????
comm.CommandText = "select count(id) from users";
count = (int)comm.ExecuteScalar();

为什么在id为text类型时就返回有错"操作数数据类型 text 对于 count 运算符无效"
用nchar(10)就行呢

是什么原因呢

如果一定要text的话,怎么能得到count值??

------解决方案--------------------
comm.CommandText = "select count(*) from users where id is not null"; 
count = (int)comm.ExecuteScalar();
------解决方案--------------------
int count=Convert.ToInt32(comm.ExecuteScalar());
你的count是怎么定义的啊?
------解决方案--------------------
sql 里面
Count函数不能操作text类型的字段
------解决方案--------------------
理解错了!呵呵^看成另外一个count了!
TEXT在SQL中,有很多字符处理函数都不支持!这也没办法的!
------解决方案--------------------
comm.CommandText = "select count(*) from users"; 
count = (int)comm.ExecuteScalar();

count(*)不成吗?
------解决方案--------------------
用nvarchar(10), 另外写成count(1)或count(*)就不存在问题了。