......
string s=....;SqlDataAdapter myCommand = new SqlDataAdapter(s, conn);
DataSet ds = new DataSet();
myCommand.Fill(ds, "count");
if(ds.Tables["count"].Rows.Count>0)
{
   label1.Text=Convert.ToInt32(ds.Tables["count"].Rows[0][0]);
          }

解决方案 »

  1.   

    不一定要count(*),可以取出来后访问属性ds.Tables["表名"].Rows.Count
      

  2.   

    public int GetRowCount(string str_Sql)
    {
    if(myReader!=null)
    myReader.Close();
    Fill(str_Sql);
    try
    {
    int count=ds.Tables[0].Rows.Count;
    ds.Clear();
    //myConnection.Close();
    return count;
    }
    catch
    {
    ds.Clear();
    //myConnection.Close();
    return 0;
    }

    }Label1.Text=GetRowCount(sqlstr);
      

  3.   

    zwztu你的myreader是一个dbreader的对象吗?如果是,是不是要在哪里声明一下?
      

  4.   

    其实用数据库查询返回都可以认为是一个DataSet
      

  5.   

    我写了一句Label2.Text=Convert.ToInt32(myDataSet.Tables["xx_bytime"].Rows.Count);在cs文件里,但是提示cannot implicitly convert type,为什么?怎么办?
      

  6.   

    Label2.Text=Convert.ToInt32(myDataSet.Tables["xx_bytime"].Rows.Count.Tostring();