Display details in a textbox
<p>I have a list box.Whenever I search a person from the database, the result will be displayed in a listbox. Then what I want is whenever I click on the name of the person from the listbox is that the persons detail will be displayed in textboxes. I have my code but the problem is that only the details of the person I first click are displayed in the textboxes.</p>

<pre><code>private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        connection.Open();
        OleDbCommand select = new OleDbCommand();
        select.Connection = connection;
        select.CommandText = "Select * From Accounts";
        OleDbDataReader reader = select.ExecuteReader();

        while (reader.Read())
        {
            if (reader[0].ToString() == listBox1.Tag.ToString())
            {
                fnametb.Text = reader[1].ToString();
                lnametb.Text = reader[2].ToString();
                agetb.Text = reader[3].ToString();
                addresstb.Text = reader[4].ToString();
                coursetb.Text = reader[5].ToString();
            }

        }
        connection.Close();

    }
</code></pre>
