我试图在Visual Studio 2012的组合框中显示oracle数据库中的表名,但我不确定它为什么不显示
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
con.Open();
OleDbDataAdapter oda = new OleDbDataAdapter("SELECT table_name FROM tabs where table_name Like 'ST%'", con);
DataTable dt = new DataTable();
oda.Fill(dt);
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "table_name";
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex + "");
}
}
答案 0 :(得分:0)
我找到了解决方案。而是双击组合框,我将代码放在表单的构造函数中,因此每次加载时,它会自动将值发送到组合框