MS访问Combobox的数据

时间:2016-05-07 22:04:01

标签: c# visual-studio ms-access combobox

我有一个用于编辑数据的表单,当我选择一个ID时,它会在我的textboxes中显示一些数据,我还想在我的position_edit中显示一些数据组合框。 到目前为止,这是我的代码:

try
{
    connection.Open();
    OleDbCommand command = new OleDbCommand();
    command.Connection = connection;
    String query = "SELECT * FROM emp WHERE ID = '" + id_edit.Text + "'";
    command.CommandText = query;
    OleDbDataReader reader = command.ExecuteReader();
    while (reader.Read())
    {
        name_edit.Text = reader["Name"].ToString();
        dob_edit.Text = reader["DOB"].ToString();
        position_edit.Items.Add ??
    }
    connection.Close();
}
catch (Exception ex)
{
    MessageBox.Show("Error " + ex);
    connection.Close();
}

感谢。

0 个答案:

没有答案