Hi Guys

I want to change the values in first combo box1 according to values in combo box2.I wore followign coding but it did nt work.I wrote in under SelectedIndexChanged in combo box
Pls give me idea how to slove this problem

private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
            SqlConnection con = new SqlConnection("Data Source=IT-TEMP;Initial Catalog=Test;Integrated Security=True");
            string str3 = "Select ExecutiveCode from dbo.Executive where TerritoryCode='"+ this.comboBox2.Text +"'";
            SqlCommand command3 = new SqlCommand(str3, con);
            SqlDataReader reader = command3.ExecuteReader();
            while (reader.Read())





Thanks for reply from dickersonka and Lizr.But still problem is there.Once I did what dickersonka mentioned above ,but no value change in first combo box

Are you sure 'this.comboBox2.Text ' returns the selected index, (and do you need value or text)?

And make sure that reader[0].ToString() returns the intended value? You may print or debug..

Also, as dickersonka said, clear the combobox not refresh.

This article has been dead for over six months. Start a new discussion instead.