You have reused the
dr
variable, thus you loose the outer DataReader on the first run of the loop. Change tho this:
con.Open();
string str = "select name from tbl where city = 'xxx' ";
cmd = new SqlCommand(str, con);
dr1 = cmd.ExecuteReader();
while (dr1.Read())
{
Label lb = new Label();
lb.Text = dr[0].ToString() + "<br>";
form1.Controls.Add(lb);
string val = "select * from othertbl where name= '" + dr[0].ToString(); +"'";
cmd = new SqlCommand(val, con);
var dr2 = cmd.ExecuteReader();
dr2.Read();
for(int a=0; a<10; a++)
{
LinkButton lbn = new LinkButton();
lbn.Text = dr2[a].ToString() + "<br>";
form1.Controls.Add(lbn);
}
}
con.Close();