2012-07-13 3 views
1

내 코드는 다음과 같습니다C# 예외에서 ORA 오류 코드를 가져 오는 방법은 무엇입니까?

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;    
    } 

내 문제는 오류 ORA-02291 오라클 발생하면, 그 예외가 catch되지 않는 것입니다. 오류가 표시되지 않습니다. 어떻게이 오류를 잡을 수 있습니까?

+0

당신이 ADO.Net 또는 ODP.Net의 OracleClient를 사용하고 있습니까? – Chandu

+0

메시지 상자에 텍스트가 없거나 메시지 상자가 표시되지 않았다는 뜻입니까? –

+0

메시지 상자가 표시되지 않았습니다. 나는 webgui와 devart를 사용하고 있습니다. 나는 그것을 얻었다. .. 그것은 webgui 문제이었다. 미안합니다.. – Marshall

답변

3

확인이 :

if (ex.InnerException != null) 
{ 
    MessageBox.Show(ex.InnerException.Message, "error!"); 
} 
2
catch (System.Data.OracleClient.OracleException ex) 
{ 
    int code = ex.Code; 

    // or 

    string eCode = ex.ErrroCode; 

    return false; 
} 
return true; 
관련 문제