how to fetch latest row update in label in asp.net

Oct 2 2014 8:53 AM
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from emp where id = max(id)"
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
reader.Read();
labelname1.Text = reader["Name"].ToString();
reader.Read();
labelname2.Text = reader["Name"].ToString();
reader.Read();
labelname3.Text = reader["Name"].ToString();
reader.Close();
con.Close();
con.Open();
SqlDataReader reader1 = com.ExecuteReader();
reader1.Read();
labelage1.Text = reader1["Age"].ToString();
reader1.Read();
labelage2.Text = reader1["Age"].ToString();
reader1.Read();
labelage3.Text = reader1["Age"].ToString();
reader.Close();
con.Close();
}
but this code is not working guys kindly help me.

Answers (3)