我正在以下面的方式使用交易范围,
var option1 = new TransactionOptions();
option1.IsolationLevel = IsolationLevel.ReadCommitted;
option1.Timeout = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["Tide:TransactionTimeout"]))
using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, option1))
{
//delete data from database
//multiple BulkInsertData in different tables of database
//update data
transactionScope.Complete();
}
没有内部事务开始。我收到了TransactionInDoubtException,我不明白为什么会发生。以前的代码运行平稳,但是从昨天突然开始,此异常引发
System.Transactions.TransactionInDoubtException:交易有疑问。 ---> System.Data.SqlClient.SqlException:COMMIT TRANSACTION请求没有相应的BEGIN TRANSACTION。在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(SqlException异常,布尔breakConnection,Action`1 wrapCloseInAction)在System.Data.SqlClient.TdsParser在System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlCommandReader(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&dataReady) Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte []缓冲区,TransactionManagerRequestType请求,字符串transactionName,TransactionManagerIsolationLevel isoLevel,Int32超时,SqlInternalTransaction事务,TdsParserStateObject stateObj,布尔值isDelegateControlRequest)。 ata.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest,String transactionName,IsolationLevel iso,SqlInternalTransaction internalTransaction,Boolean isDelegateControlRequest)at System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment跟踪)---内部异常堆栈的结尾
我以下面的方式使用Transaction Scope,var option1 = new TransactionOptions(); option1.IsolationLevel = IsolationLevel.ReadCommitted; option1.Timeout = TimeSpan.FromSeconds(...
来自异常消息