Search code examples
c#oracletimeoutodp.net

Oracle ODP.NET Timeout exception


I'm using ODP.NET in an c# application, and i'm using the following code to execute a stored procedure:

OracleCommand _cmd = new OracleCommand();
        try
        {
            _cmd.CommandTimeout = 900;
            _cmd.Connection = myConnection;
            _cmd.CommandType = CommandType.StoredProcedure;
            _cmd.CommandText = storedProcedureName;

            _cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            DisplayAnyway = true;
            ImportMessage = "General problem occured\n" + ex.Message;
            ex.ToString();
        }

My question is, how could i modify this in order to be able to do some special stuff only when a timeout exception occurs. The odp.net seems to have only a OracleException and no OracleTimeoutException or somthing like this.

Thank you!


Solution

  • Check the Code/ErrorCode properties of OracleException in order to see if you can use them for discriminating the specific error.