MySqlConnection con = new MySqlConnection("datasource=localhost;port=3306;username=root;password=Deprisa!79849;"); private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { //comboBox2,3,and 9 comboBox3.SelectedIndex = -1; comboBox3.Items.Clear(); if (con.State == ConnectionState.Closed) { con.Open(); } MySqlCommand cmd = new MySqlCommand("Select Distinct(idbrand) from machine where idtype='" + comboBox2.SelectedItem + "'", con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { comboBox3.Items.Add(rd[0]); } rd.Close(); cmd.Dispose(); } private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { comboBox9.SelectedIndex = -1; comboBox9.Items.Clear(); if (con.State == ConnectionState.Closed) { con.Open(); } MySqlCommand cmd = new MySqlCommand("select idmodel from machine where idtype='" + comboBox2.SelectedItem + "' and idmodel = '" + comboBox3.SelectedItem + "'", con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { comboBox9.Items.Add(rd[0]); } rd.Close(); cmd.Dispose(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)