我的代码如下所示:
public bool myQuery(string cmd)
{
try
{
OracleCommand command = null;
command = new OracleCommand(cmd, sqlConnection);
command.ExecuteReader();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "error!");
return false;
}
return true;
}
我的问题是在Oracle中发生错误ORA-02291
时,其异常未被捕获。没有显示错误,如何捕获此错误?
答案 0 :(得分:3)
检查一下:
if (ex.InnerException != null)
{
MessageBox.Show(ex.InnerException.Message, "error!");
}
答案 1 :(得分:2)
catch (System.Data.OracleClient.OracleException ex)
{
int code = ex.Code;
// or
string eCode = ex.ErrroCode;
return false;
}
return true;