use
SqlCommand.ExecuteScalar Method[
^]
con2.Open();
SqlCommand c1 = new SqlCommand("Select COUNT(hosting) from mastertable where [user]='" + lblnam.Text + "'", con2);
int count=(int)c1.Executescalar();
lbhosttake.Text =count.ToString();
Select COUNT(hosting) from ..
return only single value ( one row), so the row count will be one. You need to read the value of the return row with
Executescalar
method or read the value of
ds1.Tables[0].Rows[0].Cels[0]
value