I have a form with a combo Box, that is populated by pulling names in from a Database Table when it loads:
con.Open();
MySqlCommand sc = new MySqlCommand("SELECT CustomerName from bbb.Customers", con);
MySqlDataReader reader;
reader = sc.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("CustomerName", typeof(string));
dt.Load(reader);
comboBox1.ValueMember = "CustomerName";
comboBox1.DataSource = dt;
con.Close();
I can get the data no problem, but I need the associated ID with it. The ID is Column 1, and Customer Name is Column 2. How can I the ID? Do I have to add the code in 'SelectedIndexChanged' property?