Traicey 10 Posting Whiz in Training

Hey Guys

I have 2 DropDownList, with country and Province so I select country from the DDL provinces belong to that country should be populated to the Province DDL but instead Im get an Error with "INVALID COLUMN NAME fieldname" which is HK for Hong Kong, the following is the code for my second DDL which is Province any help will be highly appreciated thanx

protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        string strProvince = "sdp_DisplayProvince";
        SqlDataAdapter daProvince = new SqlDataAdapter(strProvince, conn);
        if (ddlCountry.SelectedIndex > 0)
        {
            DataSet dsProvince = new DataSet();
            daProvince.SelectCommand.CommandText = "Select ProvinceName from dbo.Province where CountryCode = " +
                ddlCountry.SelectedValue;

            try
            {
                dsProvince.Tables.Remove("Province");
            }
            catch (Exception de)
            {
                lblMsg.Text = de.Message;
            }
            daProvince.Fill(dsProvince, "Province");
            ddlProvince.DataSource = dsProvince;
            ddlProvince.DataValueField = "CountryCode";
            ddlCountry.DataTextField = "ProvinceName";
            ddlProvince.DataBind();
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.