0

I have implemented TransactionScope in c# like the following way:

public void BeginTransaction()
{
    //_isInstanceOwnTransaction = false;
    //TG: Please replace null check with extension method.
    if (CurrentTransaction == null)
    {
        TimeSpan transTime = new TimeSpan();
        CurrentTransaction = new TransactionScope(TransactionScopeOption.RequiresNew, transTime);
        _isInstanceOwnTransaction = true;
    }
}

I have a situation in which 6 SPs are executed in a single transaction. I have already set CommandTimeOut for EACH SP to 30 Mins.

For a particular instance the SPs are taking the below mentioned time to execute:

SP 1 - 0.5 Min

SP 2 - 0.5 Min

SP 3 - 0.5 Min

SP 4 - 0.5 Min

SP 5 - 20 Min

But while executing the 6th SP - I got the following error:

The operation is not valid for the state of the transaction-"Transaction Timeout"

Can anyone help me get rid from this error?

Dev D
  • 225
  • 1
  • 13
  • Did you try to increase the `CommandTimeOut` to a higher value? Your SP5 is taking 20 min which is a considerable amount of time. Also you can try to execute your 6th SP on your SQL window seperately and check the time. If it is less than 8 min then it is fine but if it is more than increasing the `CommandTimeOut` value should work for your case. – Rahul Tripathi Feb 23 '16 at 06:05
  • @RahulTripathi - But my question is that - I have set timeout for EACH SP to 30 mins so why its getting timeout when total time taken of all SP > 30 mins? – Dev D Feb 23 '16 at 06:39

0 Answers0