select Count(*) from FoodInfo A,FoodClass B where A.ClassID = B.ClassID,

[复制链接]
查看11 | 回复5 | 2012-1-7 12:10:25 | 显示全部楼层 |阅读模式
你的sql语句返回的就是一个数字,表示你符合where条件的有多少条,你要接受的话也不要这么写啊 用命令对象的ExecuteScalar方法可以得到,然后转型一下就行了。...
回复

使用道具 举报

千问 | 2012-1-7 12:10:25 | 显示全部楼层
你这查询的是行数,返回的就是一个数字。int=Convert.toInt32(cmd.ExecuteScalar())这样就可以了。...
回复

使用道具 举报

千问 | 2012-1-7 12:10:25 | 显示全部楼层
ExecuteScaler好像是这么写返回数据库执行第一列第一行值...
回复

使用道具 举报

千问 | 2012-1-7 12:10:25 | 显示全部楼层
cmd.ExecuteScalar();这样写试试,祝好运...
回复

使用道具 举报

千问 | 2012-1-7 12:10:25 | 显示全部楼层
SqlDataReader reader = new DBHelper().GetReaderObj(sql);DataSet ds = new DataSet();
reader.Fill(ds);
this.DataList1.DataSource = ds;
DataList1.DataBind...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行