I have tried to display the names of table in oracle database in visual studio 2012 in combo box but i am not sure why it is not displaying

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

                   OleDbDataAdapter oda = new OleDbDataAdapter("SELECT table_name FROM tabs where table_name Like 'ST%'", con);
                   DataTable dt = new DataTable();
                   comboBox1.DataSource = dt;
                    comboBox1.DisplayMember = "table_name";

               catch (Exception ex)
                   MessageBox.Show(ex + "");


Have you confirmed that the dataTable actually has some rows in it? The usual steps for a problem like this are: catch any errors (which you'll doing), confirm your sql statement works directly against the database and returns results, check your result in your code holds some data, double-check your display tool.
Somewhere along the way you're find what is going wrong.

What i did were i run the query in the sqldeveloper and it works. Then i tried it in visual studio it was not displaying. I did not insert any values as my aim is to display the table names rather than the valuis of the each table.. Thanks for the reply.

i found the solution. Instead double clicking on the combo box, i place the code at the contructor of the form, therefore everytime it loads, it automatically send the value to combo box

This article has been dead for over six months. Start a new discussion instead.