Microsoft 开发人员网络 > 论坛主页 > ADO.NET Data Providers > Distributed Transaction Manager
提出问题提出问题
 

已答复Distributed Transaction Manager

  • 2008年7月31日 13:13Chirag vm 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    hi to all

    i am developing web application with sqlserver 2005

    i am using subsonic for fatch insert update and delete 

    for any transaction i am using System.Transactions

    this will perfect working only one action will perform

    but when we do mulipal action like 2 record update in different table then it will generate error

    (Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool.)

     

    My Code in C# 2.0

     

    int eeplanid = 0;

    int cobradetail_id = 0;

    try

    {

    using (TransactionScope ts = new TransactionScope())

    {

    Tbeeplan objtbeeplans = new Tbeeplan();

    objtbeeplans.EeID = Convert.ToInt32(hdneeid.Value != "" ? hdneeid.Value.ToString() : "0");

    objtbeeplans.PlanID = Convert.ToInt32(ddlplanid.SelectedValue.ToString());

    objtbeeplans.MarkNew();

    objtbeeplans.Save();

    eeplanid = objtbeeplans.EePlanID;

     

    TbEEPlanCOBRADetail objcobradetail= new TbEEPlanCOBRADetail();

    objcobradetail.EePlanID = eeplanid;

    objcobradetail.QbType = Convert.ToInt32(ddlqb_type.SelectedValue.ToString());

    objcobradetail.QeCardinality = Convert.ToInt32(ddlqe_cardinality.SelectedValue.ToString());

    objcobradetail.QeType = Convert.ToInt32(ddlqe_type.SelectedValue.ToString());

    objcobradetail.QeDate = Convert.ToDateTime(txtqe_date.Text.ToString());

    objcobradetail.LocDate = Convert.ToDateTime(txtloc_date.Text.ToString());

    objcobradetail.MarkNew();

    objcobradetail.Save();

    cobradetail_id = objcobradetail.COBRADetailId;

     

    ts.Complete();

    }

    }

    catch (Exception ex)

    {

     

    }

     

     

答案

  • 2008年7月31日 15:59Nissim Natanov _MSFT_版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    The exception says that you need to enable network access for MSDTC. To enable it:

     

    open Control Panel\Administrative Tools\Component Services

    select Component Services\Computer\My Computer, right-click and choose Properties.
    On the MSDTC tab, press "Security Configuration..." and check if following options are  enabled:

    Network DTC Access

    Under Client and Administration
      Allow Remote Clients
      Allow Remote Administration

    Under Transaction Manager Communication
      Allow Inbound
      Allow Outbound
      No Authentication Required
      Enale XA Transactions

    After that, enable MSDTC application in Windows Firewall, if one is enabled.


    And then reboot your computer and retry.

     

全部回复

  • 2008年7月31日 15:59Nissim Natanov _MSFT_版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    The exception says that you need to enable network access for MSDTC. To enable it:

     

    open Control Panel\Administrative Tools\Component Services

    select Component Services\Computer\My Computer, right-click and choose Properties.
    On the MSDTC tab, press "Security Configuration..." and check if following options are  enabled:

    Network DTC Access

    Under Client and Administration
      Allow Remote Clients
      Allow Remote Administration

    Under Transaction Manager Communication
      Allow Inbound
      Allow Outbound
      No Authentication Required
      Enale XA Transactions

    After that, enable MSDTC application in Windows Firewall, if one is enabled.


    And then reboot your computer and retry.

     

  • 2008年8月4日 16:23Caddre 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    (but when we do mulipal action like 2 record update in different table then it will generate error)

     

     

    This is the reason for your error SQL Server is escalating the System.Transaction operation into distributed transaction because you are doing multiple updates in a TransactionScope which makes your operation none atomic so you need a resource manager like MSDTC. 

     

    In SQL Server 2005 you don't need a resource manager if you change your code to one transaction at a time.  You have to decide if you should use Subsonic and use resource manager or drop it and change your code because MSDTC is expensive and not enabled in hosting sites.