日期:2014-05-19  浏览次数:20521 次

请问在ASP.NET如何输出SQL查询语句的值?
表如下:
  寝室号     空位数量
    123                   1
    121                   2
    120                   2
表名叫House1,现在定义了一个Lable1控件

现在我想在Lable1控件中显示表中所有空位数量的和,
请问一下各位高手,应该怎么实现?

------解决方案--------------------
select sum(空位数量) as total from House1
------解决方案--------------------
同上

select sum(空位数量) as total from House1

Lable1.Text= total;
------解决方案--------------------
SqlConnection conn=....
SqlCommand com=new SqlCommand( "select sum(空位数量) as total from House1 ",conn);
Lable1.Text=com.ExecuteScalar().ToString();
...