Your sql is:
select id,name,gen,age,date,cont
Which means, in terms of column numbering, that 0 is id, 1 is name...
You said:
It should store the name of patient in the textbox 2
And you wrote:
textBox2.Text = dr.GetValue(0).ToString();
0 is the id.
Perhaps you should switch to names, for everything including giving your controls sensible names. Look how much easier it makes it to understand the code:
nameTextBox.Text = dr["name"].ToString();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…