tommy

tommy

  • NA
  • 32
  • 0

Displaying list of tables in Oracle DB in comboBox

Feb 11 2009 5:46 AM

Hi I'm currently trying to display All the Tables in the Oracle database.But this exception error keep blocking me...

"System.InvalidOperationException: Operation is not valid due to the current state of the object."

try
            {
                localSQL = "SELECT table_name FROM user_tables";
                OracleCommand cmdOracle = new OracleCommand(localSQL, localConnection);
                cmdOracle.CommandType = CommandType.Text;
                OracleDataReader drOracle = cmdOracle.ExecuteReader();
                while (drOracle.Read())
                {
                    tablelistBox.Items.Add(drOracle.GetOracleValue(0).ToString());
                }
            }

I've tried SELECT table_name FROM user_tables in the Oracle and it does generate the list of tables...but somehow this code does'nt work.

Any help or advice is appreciated.


Answers (2)