hi

i have created two combo boxes which contain locations and floors.
After selecting the location from the first combo need to filter the floors allocated to the selected location, to the second combo. i have allocated floors to locations in another table called floor allocate. can somebody pls help

//---Combo Box comLocationName
string Q2 = "SELECT LOCNAME FROM LOCATION ORDER BY LOCNAME ";
CommonAdapter.SelectCommand = new OleDbCommand(Q2, ConnectMe);
CommonAdapter.SelectCommand.ExecuteNonQuery();
DataSet DS2 = new DataSet();
CommonAdapter.Fill(DS2, "D");
DataTable DSTbl2 = DS2.Tables["D"];
comLocationName.DataSource = DS2.Tables[0];
comLocationName.DisplayMember = "LOCNAME";
comLocationName.ValueMember = "LOCNAME";

//---Combo comFloorName
string Q1 = "SELECT FLOORNAME FROM FLOOR ORDER BY FLOORNAME ";
CommonAdapter.SelectCommand = new OleDbCommand(Q1, ConnectMe);
CommonAdapter.SelectCommand.ExecuteNonQuery();
DataSet DS1 = new DataSet();
CommonAdapter.Fill(DS1, "D");
DataTable DSTbl1 = DS1.Tables["D"];
comFloorName.DataSource = DS1.Tables[0];
comFloorName.DisplayMember = "FLOORNAME";
comFloorName.ValueMember = "FLOORNAME";

OK so when the location changes, clear and populate the floor combo with items that match.

Hope this could help.

Sample...

//Populate first the combobox for country during form load
private void myForm_Load(object sender, EventArgs e)
{
       string[] country = new string[] {"Philippines", "India", "America" };
       cboCountry.Items.Clear();
       cboCountry.Items.AddRange(country);
}

//Suppose you have a table tblProvince that depends on what country
private void cboCountry_SelectedIndexChanged(object sender, EventArgs e)
{
       string strqry = string.Format(@"SELECT province FROM tblProvince WHERE country = {0}", cboCountry.Text);

       DataTable dt = new DataTable();
       SqlAdapter adapter = new SqlAdapter(strqry, oConn.ConnectionString);
       adapter.Fill(dt);

       cboCountry.Items.Clear();
       foreach (DataRow dr in dt.Rows)
       {
              cboCountry.Items.Add(dr[0].ToString());
       }
}

regards.

correction.

//Populate first the combobox for country during form load
private void myForm_Load(object sender, EventArgs e)
{
       string[] country = new string[] {"Philippines", "India", "America" };
       cboCountry.Items.Clear();
       cboCountry.Items.AddRange(country);
}

//Suppose you have a table tblProvince that depends on what country
private void cboCountry_SelectedIndexChanged(object sender, EventArgs e)
{
       string strqry = string.Format(@"SELECT province FROM tblProvince WHERE country = {0}", cboCountry.Text);

       DataTable dt = new DataTable();
       SqlAdapter adapter = new SqlAdapter(strqry, oConn.ConnectionString);
       adapter.Fill(dt);

       cboCountry.Items.Clear();
       
       //Populate the combobox Province
       foreach (DataRow dr in dt.Rows)
       {
              cboProvince.Items.Add(dr[0].ToString());
       }
}

its showing no value given to one or more parameters can nybody help me..plz its urgent