针对 Sql Server 2000 的 TransactionScope 错误 - 合作伙伴事务管理器已禁用对远程/网络事务的支持 [英] TransactionScope Error against Sql Server 2000 - The partner transaction manager has disabled its support for remote/network transactions

查看:10
本文介绍了针对 Sql Server 2000 的 TransactionScope 错误 - 合作伙伴事务管理器已禁用对远程/网络事务的支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试针对我的 Sql 2000 数据库为我的 Linq-to-Sql 操作设置一个简单的事务.使用 TransactionScope 它看起来像这样:

I am trying to set up a simple transaction for my Linq-to-Sql actions against my Sql 2000 database. Using TransactionScope it looks like this:

using (TransactionScope transaction = new TransactionScope())
{
    try
        {
        Store.DBDataContext dc = new Store.DBDataContext();
        Store.Product product = GetProduct("foo");
        dc.InsertOnSubmit(product);
        dc.SubmitChanges();
        transaction.Complete();
    }
    catch (Exception ex)
    {                
        throw ex;
    }
}

但是,我不断收到以下错误:

However, i keep getting the following error:

合作伙伴事务管理器已禁用对远程/网络事务的支持.(来自 HRESULT 的异常:0x8004D025)

但是,如果我使用传统事务来设置事务,它就可以正常工作.所以这很好用:

But, if I set up the transaction using a traditional transaction, it works fine. So this works fine:

Store.DBDataContext dc = new Store.DBDataContext();
try
{
    dc.Connection.Open();
    dc.Transaction = dc.Connection.BeginTransaction();
    Store.Product product = GetProduct("foo");
    dc.InsertOnSubmit(product);
    dc.SubmitChanges(); 
    dc.Transaction.Commit();
}
catch (Exception ex)
{
    dc.Transaction.Rollback();
    throw ex;
}
finally
{
    dc.Connection.Close();      
    dc.Transaction = null;
}

我想知道 TransactionScope 在幕后做的事情是否与我的第二个实现有所不同.如果没有,我不使用 TransactionScope 会失去什么?此外,关于导致错误的原因的任何指导也很好.我已经确认 MSDTC 正在 sql server 和我的客户端机器上运行.

I'm wondering if the TransactionScope is doing something different under the covers than my second implementation. If not, what am I losing by not using TransactionScope? Also, any guidance on what is causing the error would be good too. I've confirmed that MSDTC is running in both sql server and on my client machine.

推荐答案

看这里:

使用 System.Transactions 和 Microsoft SQL Server 2000 的快速事务http://blogs.msdn.com/florinlazar/archive/2005/09/29/475546.aspx

Fast transactions with System.Transactions and Microsoft SQL Server 2000 http://blogs.msdn.com/florinlazar/archive/2005/09/29/475546.aspx

这里:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=230390&SiteID=1

首先验证Distribute Transaction Coordinator"服务是在数据库服务器计算机和客户端计算机上运行
1. 前往管理工具 > 服务"
2.如果没有运行Distribute Transaction Coordinator"服务,开启

First verify the "Distribute Transaction Coordinator" Service is running on both database server computer and client computers
1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not running

如果它正在运行并且客户端应用程序与它不在同一台计算机上数据库服务器,在运行数据库服务器的计算机上
1. 进入管理工具 > 组件服务"
2. 在左侧导航树中,进入组件服务 > 计算机 > 我的电脑"(部分节点可能需要双击等待需要时间来扩展)
3. 右击我的电脑",选择属性"
4. 选择MSDTC"标签
5. 点击安全配置"
6. 确保选中网络 DTC 访问"、允许远程客户端"、允许入站/出站"、启用 TIP"(某些选项可能不有必要,请尝试获取您的配置)
7.服务将重启
8. 但如果它仍然无法工作,您可能需要重新启动服务器(这是之前让我发疯的事情)

If it is running and client application is not on the same computer as the database server, on the computer running database server
1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers > My Computer" (you may need to double click and wait as some nodes need time to expand)
3. Right click on "My Computer", select "Properties"
4. Select "MSDTC" tab
5. Click "Security Configuration"
6. Make sure you check "Network DTC Access", "Allow Remote Client", "Allow Inbound/Outbound", "Enable TIP" (Some option may not be necessary, have a try to get your configuration)
7. The service will restart
8. BUT YOU MAY NEED TO REBOOT YOUR SERVER IF IT STILL DOESN'T WORK (This is the thing drove me crazy before)

在您的客户端计算机上使用上述相同的步骤打开安全配置"设置,确保选中网络DTC访问",允许入站/出站"选项,重新启动服务和计算机如有必要.

On your client computer use the same above procedure to open the "Security Configuration" setting, make sure you check "Network DTC Access", "Allow Inbound/Outbound" option, restart service and computer if necessary.

在您的 SQL 服务器服务管理器上,单击服务"下拉菜单,选择分布式事务协调器",它也应该运行您的服务器计算机.

On you SQL server service manager, click "Service" dropdown, select "Distribute Transaction Coordinator", it should be also running on your server computer.

这篇关于针对 Sql Server 2000 的 TransactionScope 错误 - 合作伙伴事务管理器已禁用对远程/网络事务的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆