I was trying to fetch the "Age" from the table "tbl_Stud". The code is below. Earlier the line " lblAge.Text = dt.Rows[0]["Age"].ToString(); " was displaying a " There is no row at position 0. " error. Then I tried defending it like this,
if(dt.Rows.Count > 0)
{
lblAge.Text = dt.Rows[0]["Age"].ToString();
}
else
{
lblAge.Text = "0";
}
and now, the code displays a 0 for every entry.
Please help me.