我是 C# 新手,我正在尝试将组合框与访问数据库绑定。我用列名绑定了组合框,但我无法根据组合框的选择在文本框中显示详细信息(列)的值。
在我的数据库中有一个包含 3 列 1.id 2.wesitename 3.Details 的表,这是我的代码
 private void button1_Click_1(object sender, EventArgs e)
        {
 string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\nazarmak\\Documents\\newwebsite.accdb;Persist Security Info=True";
        OleDbConnection con = new OleDbConnection(ConnectionString);
        OleDbCommand cmd = new OleDbCommand("select websitename, Details from newweb", con);
        OleDbDataAdapter da = new OleDbDataAdapter();
         DataTable dt = new DataTable();
        try
        {
            con.Open();
            da.SelectCommand = cmd;
            da.Fill(dt);
            this.comboBox1.DisplayMember = "websitename";
            this.comboBox1.ValueMember = "websitename";
            this.comboBox1.DataSource = dt;
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            con.Close();
        }
    }