SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["xys"].ConnectionString); 
            conn.Open();
            SqlDataAdapter b = new SqlDataAdapter("select count(*) from xys_plus_company_UserInfo where joinin is not null", conn);
            DataTable x = new DataTable();
            b.Fill(x);
            conn.Close();
            this.ytxt.Text = b.Fill(x).ToString(); 

解决方案 »

  1.   

    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["xys"].ConnectionString); 
    conn.Open();
    SqlDataAdapter b = new SqlDataAdapter("select count(*) from xys_plus_company_UserInfo where joinin is not null", conn);
    DataTable x = new DataTable();
    b.Fill(x);
    conn.Close();
    if (x != null && x.Rows.Count = 1)
    {
        this.ytxt.Text = b.Rows[0][0].ToString();
    }
      

  2.   

    conn.Close();
    if(b.Fill(x).Rows.Count>0)
    {
    this.ytxt.Text = b.Rows[0]["字段名"].ToString(); //如果你取到不是条记录 那么就要去循环b.Fill(x)了 b.Fill(x) 返回的是一个  datatable你不能直接赋值给text只能b.Rows[0]["字段名"].ToString(); 
    }
      

  3.   

    if (x != null && x.Rows.Count = 1)
    {
        this.ytxt.Text = b.Rows[0][0].ToString();
    }
      

  4.   

    谢谢你们 我用你们的方法都一遍 B里面没有ROWS属性,而改为DATASET 只能执行一次DATASET 输出结果为1
     后面根据你们的提示将B改为X就好了