OracleCommand get Error
Posted: Fri 08 Aug 2014 19:03
hi, first it all, i will show the following code :
private void btnExecute_Click(object sender, EventArgs e)
{
try
{
OracleCommand oracleCommand = new OracleCommand();
oracleCommand.Connection = this.oracleConnection;
oracleCommand.CommandType = CommandType.Text;
//oracleCommand.CommandText = this.textBox.Text;
oracleCommand.CommandText = "CREATE OR REPLACE FUNCTION SOME_FUNC_RETURNING_A_CURSOR RETURN SYS_REFCURSOR IS\n" +
" CSRLOCAL SYS_REFCURSOR;\n" +
" BEGIN\n" +
" OPEN CSRLOCAL FOR SELECT WHATEVER FROM WHEREVER;\n" +
" RETURN CSRLOCAL;\n" +
" END SOME_FUNC_RETURNING_A_CURSOR;\n";
oracleCommand.ExecuteNonQuery();
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
So when execute this command the error dotconnect show me is :
---------------------------
---------------------------
Code 24344 Mesage ORA-24344: correcto con error de compilación
---------------------------
OK
---------------------------
However this error code was captured in the oracleConnection_Error event,
private void oracleConnection_Error(object sender, Devart.Data.Oracle.OracleConnectionErrorEventArgs e)
{
MessageBox.Show("Error : Code " + e.Code + " Mesage " + e.Message);
}
So my questions are
- This is the normal scenario in order to catch the executions?
- Why OracleConnectionErrorEventArgs object does not provide me the information about line, Offset as OracleScript and OracleException provide?
-It should be oracleCommand.ExecuteNonQuery(); generated a OracleException in order to get the error information in the
Catch (OracleException)
{
// here
}
private void btnExecute_Click(object sender, EventArgs e)
{
try
{
OracleCommand oracleCommand = new OracleCommand();
oracleCommand.Connection = this.oracleConnection;
oracleCommand.CommandType = CommandType.Text;
//oracleCommand.CommandText = this.textBox.Text;
oracleCommand.CommandText = "CREATE OR REPLACE FUNCTION SOME_FUNC_RETURNING_A_CURSOR RETURN SYS_REFCURSOR IS\n" +
" CSRLOCAL SYS_REFCURSOR;\n" +
" BEGIN\n" +
" OPEN CSRLOCAL FOR SELECT WHATEVER FROM WHEREVER;\n" +
" RETURN CSRLOCAL;\n" +
" END SOME_FUNC_RETURNING_A_CURSOR;\n";
oracleCommand.ExecuteNonQuery();
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
So when execute this command the error dotconnect show me is :
---------------------------
---------------------------
Code 24344 Mesage ORA-24344: correcto con error de compilación
---------------------------
OK
---------------------------
However this error code was captured in the oracleConnection_Error event,
private void oracleConnection_Error(object sender, Devart.Data.Oracle.OracleConnectionErrorEventArgs e)
{
MessageBox.Show("Error : Code " + e.Code + " Mesage " + e.Message);
}
So my questions are
- This is the normal scenario in order to catch the executions?
- Why OracleConnectionErrorEventArgs object does not provide me the information about line, Offset as OracleScript and OracleException provide?
-It should be oracleCommand.ExecuteNonQuery(); generated a OracleException in order to get the error information in the
Catch (OracleException)
{
// here
}