none OracleCommand does not throw timeout exception (executing stored procedure) RRS feed

  • Question

  • Dear All,

    I am executing a ORACLE Stored procedure using System.OracleClient.OracleCommand and set CommandTimeout = 5; (for example)

    But I want to set a timeout such that if the command object execution takes more than say 5 minutes it should get aborted (getting exception...OracleException) so that I can show an error message to the user. Let me know how can this be done. This is my written code example.

            var cmdOracle = new OracleCommand("hfghgh", _dbConnectionString)
                CommandType = CommandType.StoredProcedure
            cmdOracle.Parameters["inputParam"].Value = 1;                
            tran =_dbConnectionString.BeginTransaction(IsolationLevel.ReadCommitted);
            cmdOracle.Transaction = tran;
            cmdOracle.CommandTimeout = 5;
            await cmdOracle.ExecuteNonQueryAsync();
            return res = cmdOracle.Parameters["outputParam"].Value.ToString();
        catch (OracleException ex)
            dynamic exOra = ex;
            int errorNo = exOra.Number;
            if (errorNo == 01013)
                throw new ResponseFailException(ex);
                throw ex;

    Can you suggest any way to solve that problem?



    Thursday, September 6, 2018 7:03 AM