Try to use the SelectionChangeCommitted instead. The SelectedValueChanged event is raised during binding and in this context the actual values DisplayMember and ValueMember are not properly set
private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
{
// Better to be safe here.....
if (this.comboBox1.SelectedValue == null)
return;
using(OleDbConnection con = new OleDbConnection(connectionString))
using(OleDbDataAdapter da2 = new OleDbDataAdapter("SELECT * FROM [" +this.comboBox1.SelectedValue.ToString() +"]", con))
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
da2.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da2.Fill(dt);
this.dataGridView1.DataSource = dt;
}
}
See also this question for a better explanation of the problem