2

我正在调用一个完整的服务,它反过来在 sql server 数据库中执行批量插入。当休息服务器和数据库服务器在同一台机器上时,一切正常,但在远程数据库服务器的情况下,出现以下异常。

System.InvalidOperationException: The transaction associated with the current 
connection has completed but has not been disposed.
The transaction must be disposed before the connection can be used to
execute SQL statements.

我正在使用以下交易。

TransactionOptions tOptions = new TransactionOptions();
tOptions.IsolationLevel = IsolationLevel.ReadCommitted;
//This transaction is required here as it checks for all db operations.
using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, tOptions))
{
    //DB operations....
    transactionScope.Complete();
}
4

1 回答 1

1

在我的 IIS 服务器上配置 windows MSDTC 服务就可以了。

以下链接显示如何配置 MSDTC。

http://www.deepakkapoor.net/turn-on-msdtc-windows-7/

于 2012-09-14T04:25:29.400 回答