When trying to display a list of values ​​in ComboBox from a query to an Oracle database, a request error is issued:

-2147467259 - Oracle.ManagedDataAccess.Client.OracleErrorCollection

Oracle.ManagedDataAccess version 4.122.18.3

The code block itself:

public static class Setting { public static string ora_connect = "User Id=***;Password=***;Data Source=***"; public static string ora_street = "SELECT STREET, trim(NAME) NAME from address;"; } private void comboBox1_DropDown(object sender, EventArgs e) { OracleConnection connection = new OracleConnection(Setting.ora_connect); try { connection.Open(); OracleCommand command = new OracleCommand(Setting.ora_street, connection); OracleDataAdapter adapter = new OracleDataAdapter(command); OracleDataReader reader = command.ExecuteReader(); DataTable data = new DataTable(); data.Columns.Add("Name", typeof(string)); data.Columns.Add("Streets", typeof(Int32)); data.Load(reader); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Streets"; comboBox1.DataSource = data.DefaultView; connection.Close(); connection.Dispose(); } catch (OracleException ex) { MessageBox.Show("Ошибка запроса!"); MessageBox.Show(ex.ErrorCode + " - " + ex.Errors); System.Windows.Forms.Application.Exit(); } } 
  • It would be nice to all in using'i wrap. | adapter is not used. It is necessary either to throw it out, or use it to fill in the datable: adapter.Fill, and then you can throw out the reader. - Alexander Petrov
  • Yes. Noticed that adapter is not used. Removed completely. @ alexander-petrov didn’t quite understand about the wrapper in using - I’m just learning and I can write wrong code somewhere. - Gam_off

1 answer 1

Question solved: Removed semicolon from request

"SELECT STREET trim (NAME) NAME from address";