[英]Should I enable MSDTC in webserver or Database server when using “TransactionScope”?
My question is related to this topic TransactonScope . 我的问题与这个主题TransactonScope有关 。 I have a web server and a database server and a remote database server. 我有一个Web服务器,一个数据库服务器和一个远程数据库服务器。 I want to have a distributed transaction between local and remote server. 我想在本地和远程服务器之间进行分布式事务。 I configured MSDTC for database servers and I can have a distributed transaction in Database servers with linked server. 我为数据库服务器配置了MSDTC,并且可以在具有链接服务器的数据库服务器中进行分布式事务。 but when I use Transaction scope in system.transactions
name space I encounter following error when I Just open the second connection (Remote Connection). 但是,当我Transaction scope in system.transactions
命名空间中使用Transaction scope in system.transactions
时,我仅打开第二个连接(远程连接)时遇到以下错误。
error:
The transaction has already been implicitly or explicitly committed or aborted.
simplified code: 简化代码:
using (TransactionScope tscope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
//open connection db 1
//insert into db1
//open connection db2 (Remote databse) -- the problem is here
//insert into db2
tscope.Complete();
}
您应该启用它,因为运行时“必要时”会将事务升级为使用分布式事务处理协调器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.