简体   繁体   English

与远程SQL Server批量插入的异常

[英]Exception with bulk insert with remote sql server

I am calling a rest full service which in turn performs bulk insert in sql server database. 我正在调用其余的完整服务,该服务又在sql server数据库中执行批量插入。 Every thing works fine when rest server and the database server are on same machine, but in case of remote database sever following exception is encoutered. 当其余服务器和数据库服务器位于同一台计算机上时,一切正常,但是在远程数据库服务器的情况下,将引发以下异常。

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.

I am using following transactions. 我正在使用以下交易。

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();
}

Configuring the windows MSDTC service on my IIS server did the trick. 在我的IIS服务器上配置Windows MSDTC服务可以解决问题。

The following link shows how to configure MSDTC. 以下链接显示了如何配置MSDTC。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM