I'm trying to load two values of a table into a combobox
What I need is that in my combobox the value nom_lugar is shown and that the id is assigned as a value to be able to enter it in the bd
DateTime date = DateTime.Now;
lbl_fecha.Text = date.ToShortDateString();
try
{
MySqlConnection con = new MySqlConnection("server=localhost;
database=rier; Uid=rir; pwd=root; SslMode=none");
string selectQuery = "select * from lugar";
con.Open();
MySqlCommand command = new MySqlCommand(selectQuery, con);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read()) {
comboBox1.Items.Add(reader.GetString("id_lugar"));
comboBox1.SelectedValue = "id_lugar";
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}