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サーバーでWindowsMSDTCサービスを構成することでうまくいきました。

次のリンクは、MSDTCを構成する方法を示しています。

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

于 2012-09-14T04:25:29.400 に答える