Combox对SQL中的两个字段进行多级查询应该怎么办啊?
在highFireForestry表中有乡名和村名两个字段,要用combobox1选中乡名作为条件,然后再在combobox2中选择村名。string str = "server=.;database=火险评价与资源配置数据;integrated security=true";
SqlConnection conn = new SqlConnection(str);//创建一个新连接
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.Connection = conn;
cmd.CommandText = "select 乡名 from highFireForestry";//在这儿写sql语句
SqlDataReader dr = cmd.ExecuteReader();//创建一个SqlDateReader对象
while (dr.Read())
{
comboBox1.Items.Add(dr[0]);
}
SqlDataAdapter newdata = new SqlDataAdapter("select 村名 from highFireForestry where 村名='" + comboBox1.SelectedItem.ToString() + "'", conn);
conn.Close(); --------------------编程问答--------------------
补充:.NET技术 , C#