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