使用所选项目更改组合框 c# 从数据库加载文本框

Load Textbox from database using selected item changed combobox c#

当我尝试加载包含两个组合框和两个文本框的表单时出现异常 我从数据库加载 Combobox 项目,我尝试从 table Bureau 加载数据并将它们填充到两个文本框中 图片 : [我得到的异常]

[我的表格]

public partial class Modifier : Form
{

    public DataSet ds = new DataSet();

    public DataSet ds2 = new DataSet();

    public SqlCeConnection conn = new SqlCeConnection(@"Data Source=\Program Files\projetpfe\Inventaire.sdf");

    public SqlCeDataAdapter da, da2;
    public SqlCeCommand cmd, cmd2;
    public SqlCeDataReader dr,dr2;
    public Modifier()
    {
        InitializeComponent();

        this.da = new SqlCeDataAdapter("Select Code_locale from Bureau", conn);
        this.da2 = new SqlCeDataAdapter("Select DISTINCT Adresse from Bureau ", conn); 
        this.cmd = new SqlCeCommand("Select * from Bureau where Code_locale='" + comboBox1.SelectedValue + "'", conn);

        conn.Open();

    }

    private void Modifier_Load(object sender, EventArgs e)
    {

        this.ds.Tables.Clear();
        this.da.Fill(this.ds, "Bureau");
        comboBox1.DataSource = this.ds.Tables["Bureau"];
        comboBox1.DisplayMember = "Code_locale";
        this.ds2.Tables.Clear();
        this.da2.Fill(this.ds2, "Bureau");
        comboBox2.DataSource = this.ds2.Tables["Bureau"];
        comboBox2.DisplayMember = "Adresse";
        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            textBox1.Text = dr[1].ToString();
            textBox2.Text = dr[2].ToString();
        }
    }

我解决了我的问题,我使用了事件组合框选择更改,我将所有代码复制到组合框选择更改事件,它解决了我的问题,当我选择一个组合框项目时,文本框显示数据阅读器