select sum(*) from table

解决方案 »

  1.   

    SqlCommand cmd = new SqlCommand("Select Count(*) from table","数据库连接");int count;
    try {
      count = (int)cmd.ExecuteScalar();  //一定要try,否则如果没有数据,这里转型会出错
    }
    catch {
      count = 0;
    }
      

  2.   

    Sum是统计字段的值,Count才是统计记录的数量
      

  3.   

    string comstr="select count(*) from table where...";
    SqlCommand mycom=new SqlCommand(con,comstr);
    int count=(int)mycom.ExecuteScalar();
      

  4.   

    Select count(*) from table
      

  5.   

    sqlcommand sqlcmd=new sqlcommand(sqlconn,"select * from table")
    int RowCount=sqlcmd.executereader()
      

  6.   

    int RowCount=sqlcmd.executereader()
    这个可以么,我现在不能试
      

  7.   

    >>int RowCount=sqlcmd.executereader()
    >>这个可以么,我现在不能试可以,但最好用 ExecuteScalar()
      

  8.   

    Select Count(*) from tableint RowCount=sqlcmd.ExecuteScalar();
      

  9.   

    如果没有数据,应该会返回0,因为你用的是select count(*) from yourtable.
      

  10.   

    dataset.table[0].rows.count