I an new in creating programs in Visual Studio C#. I want to create a program that reads the information from MySQL and display the selected information in a textbox. What I have here is a code for displaying the information in a combobox.
This is the code to display information from MySQL in a combobox:
private void comboBoxDistrict_SelectedIndexChanged(object sender, EventArgs e)
{
comboBoxDistrictName.Items.Clear();
string query = "SELECT employee_lastname, employee_firstname, employee_middlename FROM employee WHERE employee_district = '" + comboBoxDistrict.Text.ToString() + "'";
DBConn db = new DBConn();
DataTable tbl = db.retrieveRecord(query);
foreach (DataRow row in tbl.Rows)
comboBoxDistrictName.Items.Add(row[0].ToString() + ", " + row[1].ToString() + " " + row[2].ToString());
}
What I need is to display the information in a textbox. Please help. Thanks.
Just Change the assign from your
ComboBoxto be yourtextBoxYou may take care of iteration, since just last row in this case will be shown in the
textBox