I want to display all e-mail addresses from my database in a TextBox. The reason I want to use a TextBox is that I want them in a single row, separated by "; " and that's not possible in a ListBox (right?) which I was using from the beginning.
So - I want to change my "display in ListBox"-code to "display in TextBox"-code. It doesn't seem to be enough just to change ListBox.Items.Add to TextBox.Text (as shown in code below), so what do I have to do to make it work (collect all addresses in an array first and then from there to the TextBox is a thought I'm having but maybe there's a better way)? The TextBox Mode is set to MultiLine.
SqlConnection conn = new SqlConnection(config);
conn.Open();
string sql = "SELECT email FROM NewslttrRep";
SqlCommand comm = new SqlCommand(sql, conn);
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
TextBoxEmailNewsletter.Text = (dr[0] + "; "); //only the last e-mail address in the database table is displayed
}
dr.Close();
conn.Close();