Hi,
Try the below code
string query = "select count(*) as number from tblRegNo";
SqlCommand cmd= new SqlCommand(query,con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
int noOfRecords=0;
If(ds.Table[0].Rows.Count>0)
{
noOfRecords = Convert.ToInt32(ds.Table[0].Rows[0]["number"].ToString());
}