对一张空表查询 select max() from table 时 dataReader.hasRows属性为什么为空
如题当对一张空表查询 当使用
          string sqlStr ="select * from table";
          SqlDataCommand cmd=new SqlDataCommand(sqlStr,conn);
            SqlDataReader dataReader = cmd.ExecuteNonQuery();
        时dataReader.HasRows属性为false
但是当使用
     sqlStr ="select max(count) as count from table";
          SqlDataCommand cmd=new SqlDataCommand(sqlStr,conn);
            SqlDataReader dataReader = cmd.ExecuteNonQuery();
        时dataReader.HasRows属性为true
这是为什么呢

解决方案 »

  1.   

    select * from table  没有数据就不返回任何行
    select max(count) as count from table   没有数据就返回null行
      

  2.   

    第一个是查记录
    第二个用聚合函数,始终会有一个返回值,如果没有记录就会返回null
      

  3.   

    那SQL里面返回null行的 都有哪些函数呢
      

  4.   

    其实我不明白,SqlDataReader dataReader = cmd.ExecuteNonQuery();为什么会不报错的