adapter = new SqlDataAdapter("select * from train", cn); SqlCommand cmd = new SqlCommand("select * from train", cn); cmd.Parameters.Clear(); adapter.Fill(ds, "train"); comboBox1.DataSource = ds.Tables["train"]; comboBox1.DisplayMember = "id"; comboBox1.ValueMember = "id"; adapter = new SqlDataAdapter("select id_w from wagon where id='" + comboBox1.SelectedValue + "'", cn); adapter.Fill(ds, "wagon"); // adapter1.SelectCommand.Parameters.Clear(); comboBox2.DataSource = ds.Tables["wagon"]; comboBox2.DisplayMember = "id_w"; comboBox2.ValueMember = "id_w";
adapter = new SqlDataAdapter("select id_w from wagon where id = @id", cn); adapter.SelectCommand.Parameters.AddWithValue("@id", comboBox1.SelectedValue);
private void train_SelectedIndexChanged(object sender,System.EventArgs e) { //Load the wagon_details and populate in combobox. }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)