简体   繁体   English

使用“ TransactionScope”时,应该在Web服务器或数据库服务器中启用MSDTC吗?

[英]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.

相关问题 使用TransactionScope时避免启用MSDTC - Avoid enabling MSDTC when using TransactionScope TransactionScope:连接将升级到MSDTC - TransactionScope: When connection will be escalated to MSDTC 我应该在使用.Net Cache时添加Locks还是TransactionScope? - Should I add Locks or TransactionScope when using .Net Cache? .NET TransactionScope和MSDTC - .NET TransactionScope and MSDTC 如果禁用MSDTC,如何绕过TransactionScope内的多个数据库连接? - How do you get around multiple database connections inside a TransactionScope if MSDTC is disabled? 如何在SQLCLR中使用TransactionScope而不升级到MSDTC - How to use TransactionScope in SQLCLR without escalation to MSDTC TransactionScope会在某些机器上自动升级到MSDTC吗? - TransactionScope automatically escalating to MSDTC on some machines? 我应该从TransactionScope TransactionCompleted事件中注销吗? - Should I unregister from TransactionScope TransactionCompleted event? 数据库未使用TransactionScope更新 - Database doesn't update using TransactionScope 当一个是SQL Server CE时,如何将TransactionScope与两个数据库一起使用? - How do I use a TransactionScope with two databases when one is SQL Server CE?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM