Handling request errors in OracleDataAdapter.Fill()

303 Views Asked by At

I am writing a client application using System.Data.OracleClient. With an error in writing a select query when calling the OracleDataAdapter.Fill (DataSet) function, I understand that an error occurs inside, but the program, when executing this function, interrupts the execution of the body of the function in which this string is located. Binding OracleDataAdapter.Fill Error event or "try" construct does not fire. How can I catch errors like this?

string select = "SELECT qwe FROM employee"; // 'employee' does not contain 'qwe'
OracleDataAdapter adapter = new OracleDataAdapter(select, connection);
adapter.FillError += Adapter_FillError;
try
{
    adapter.Fill(ds, "zak");
}
catch (OracleException ex)
{
    MessageBox.Show(ex.Message);
}
private void Adapter_FillError(object sender, FillErrorEventArgs e)
{
    MessageBox.Show(e.Errors.Message);
}
0

There are 0 best solutions below