Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:58:53+00:00 2026-06-13T19:58:53+00:00

ODP.NET documentation for OracleCommand.CommandTimeout says Default is 0 seconds, which enforces no time limit.

  • 0

ODP.NET documentation for OracleCommand.CommandTimeout says

Default is 0 seconds, which enforces no time limit.

When the specified timeout value expires before a command execution
finishes, the command attempts to cancel. If cancellation is
successful, an exception is thrown with the message of ORA-01013: user
requested cancel of current operation. If the command executed in time
without any errors, no exceptions are thrown.

In a situation where multiple OracleCommand objects use the same
connection, the timeout expiration on one of the OracleCommand objects
may terminate any of the executions on the single connection. To make
the timeout expiration of a OracleCommand cancel only its own command
execution, simply use one OracleCommand for each connection if that
OracleCommand sets the CommandTimeout property to a value greater than
0.

But a code like this works:

static void Main(string[] args)
{
    OracleConnection conn = null;
    try
    {
        string connString =
            "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myOracleHost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=myServiceName)));User Id=system;Password=admin;Pooling = False;";
        string cmdString1 = "UPDATE employee SET empname = 'temp1' where id = 1";
        string cmdString2 = "Update employee set empname = 'temp2' where id = 2";
        conn = new OracleConnection(connString);
        var cmd1 = new OracleCommand(cmdString1, conn);
        cmd1.CommandTimeout = 30;
        var cmd2 = new OracleCommand(cmdString2, conn);
        cmd2.CommandTimeout = 30;
        conn.Open();
        try
        {
            //Locked the row with ID 1 with an uncommitted update operation outside this code
            cmd1.ExecuteNonQuery();
        }
        catch (Exception exception)
        {
            //Exception ORA-01013 Thrown as expected
        }
        try
        {
            //As per the documentation, this should not also work since this command object also uses the same connection as above and it timed out in the query above
            cmd2.ExecuteNonQuery();
            //But this still works fine. 
        }
        catch (Exception)
        {
            //no exception
        }
    }
    finally
    {
        conn.Close();
    }
}

I am using the same OracleConnection object for both the command objects – cmd1 and cmd2, and cmd1 already timed out(as expected).
But, per the documentation, cmd2 also should not run. But it still runs without any exception and updates the other row properly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:58:55+00:00Added an answer on June 13, 2026 at 7:58 pm

    You do not have multiple commands running on the connection, you have two commands running sequentially, one after the other. When the first command times out, there is no other command pending on the connection. Your code does not submit the second command for execution until after the first command has either succeeded or has thrown an exception.

    The last paragraph from the documentation you quoted should read: In a situation where multiple OracleCommand objects use the same connection simultaneously, …

    static void Main(string[] args)
    {
        using (var conn = new OracleConnection("Pooling=False;...")) // why?
        using (var cmd1 = conn.CreateCommand())
        using (var cmd2 = conn.CreateCommand())
        {
            cmd1.CommandText = "UPDATE employee SET empname = 'temp1' WHERE id = 1";
            cmd2.CommandText = "UPDATE employee SET empname = 'temp2' WHERE id = 2";
            cmd1.CommandTimeout = 30;
            cmd2.CommandTimeout = 30;
    
            conn.Open();
    
            // there are no commands on conn yet
    
            try { cmd1.ExecuteNonQuery(); } // cmd1 is the only command on conn
            catch (OracleException) { } // if timeout, no other command affected
    
            // cmd1 is no longer on conn
    
            try { cmd2.ExecuteNonQuery(); } // cmd2 is the only command on conn
            catch (OracleException) { } // if timeout, no other command affected
    
            // cmd2 is no longer on conn
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute a packageprocedure from ODP.NET C# which insert data into
Today I found the OracleCommand.InitialLOBFetchSize property ( documentation ). Because I'm using NHibernate (which
ODP.NET 11.2.0.3.0 was released on December 28, 2011 and its description says that it
We are currently deploying our .net winform application which depends on ODP.NET 2.111.6.20 via
Just migrated ODP.NET 11.2 Release 4 from Devart DotConnect for Oracle http://www.devart.com/dotconnect/oracle/ but I
I am having trouble getting the ODP.NEt library to work with the .NET DBProviderFactories.
I have some code that uses ODP.Net using (OracleConnection connection = new OracleConnection(connectionString)) {
More specifically I want to test whether Oracle ODP.Net is installed on a machine.
I'm trying to work with EF CodeFirst under Oracle with ODP.net. This is my
I am using Oracle 11g client, with ODP.NET. I am trying to add conditional

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.