“The operation is not valid for the state of the transaction” error and transaction scope

后端 未结 6 865
轮回少年
轮回少年 2020-12-02 14:13

I am getting the following error when I try to call a stored procedure that contains a SELECT Statement:

The operation is not valid for the state of t

6条回答
  •  盖世英雄少女心
    2020-12-02 14:28

    I also come across same problem, I changed transaction timeout to 15 minutes and it works. I hope this helps.

    TransactionOptions options = new TransactionOptions();
    options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
    options.Timeout = new TimeSpan(0, 15, 0);
    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,options))
    {
        sp1();
        sp2();
        ...
    
    }
    

提交回复
热议问题