onchange事件中,根据内容区select数据集,然后遍历数据集,添加到items

解决方案 »

  1.   


    选择a,返回b
      private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                string Sql = "select b from table where a =' " + comboBox1.SelectedItem  + "'' ";
                string connectionString = "Data Source=192.168.1.3;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False";
                string queryString = Sql;
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand command = new SqlCommand(queryString, connection);
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            textBox1.Text = reader[0].ToString();                                                
                        }
                    }
                    finally
                    {
                        command.Dispose();
                        connection.Close();                }
                }  
            }
      

  2.   

    select * from phonetable where name like '%"+txtBoxID.text+"%'
      

  3.   

    http://bbs.csdn.net/topics/390324804
    像百度那样的