سلام دوست عزیز شما با ExecuteScalar به راحتی میتونید این کار رو انجام بدید
نمونه کد:
string sql = "SELECT count(*) FROM stud where avg>=17";
SqlCommand cmd = new SqlCommand(sql, con);
int bes = (int)cmd.ExecuteScalar();
سلام دوست عزیز شما با ExecuteScalar به راحتی میتونید این کار رو انجام بدید
نمونه کد:
string sql = "SELECT count(*) FROM stud where avg>=17";
SqlCommand cmd = new SqlCommand(sql, con);
int bes = (int)cmd.ExecuteScalar();