不需要,com+中的事务可以跨数据源,ado .net中提供的事务只能在一个数据源中起作用。com+的事务比ado.net中的事务也更灵活。

解决方案 »

  1.   

    楼上在进行多层架构的程序开发中是怎样使用Com+事务与Ado .net事物的
      

  2.   

    同意lanbaibai(蓝白白)但是Com+事务比Ado .net事务耗性能.但是要分布式开发跨层可能不行.请高手明示
      

  3.   

    进行多层架构的程序开发中是怎样使用Com+事务与Ado .net事务
      

  4.   

    在多层中 只需要将事务作在com+里面就可以了
      

  5.   

    .NET Framework 依靠 MTS/COM+ 服务来支持自动事务。COM+ 使用 Microsoft Distributed Transaction Coordinator (DTC) 作为事务管理器和事务协调器在分布式环境中运行事务。这样可使 .NET 应用程序运行跨多个资源结合不同操作(例如,将定单插入 SQL Server 数据库、将消息写入 Microsoft 消息队列 (MSMQ) 队列、以及从 Oracle 数据库检索数据)的事务。Com+事务是基于操作系统的,由于存在 DTC 和 COM 互操作性开销,导致性能降低
      

  6.   

    请大家帮忙,下面是个例子:
    public class Class1
    {
    public bool TranDemo()
    {
    SqlConnection conn = new SqlConnection("server = localhost;User id = sa; password =centaurus;database=Northwind");
    conn.Open(); SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    SqlTransaction tran=conn.BeginTransaction();
    cmd.Transaction=tran;
    try
    {
    cmd.CommandText = "update Products set unitPrice =  100 where ProductID =1";
    cmd.ExecuteNonQuery();

    tran.Commit();

    return true; }
    catch (Exception e)
    {

    tran.Rollback();
    return false;
    } }
    }
    另一个:
    public class Tran 
    {
    public bool TranDemo()
    {
    SqlConnection conn = new SqlConnection("server = wfw;User id = sa; password =centaurus;database=Northwind");
    conn.Open(); SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;

    try
    {
    Class1 c=new Class1();
    c.TranDemo();
    cmd.CommandText = "update Products set unitPrice =  105 where ProductID =1";
    cmd.ExecuteNonQuery();
    return true; }
    catch (Exception e)
    {
    return false;
    } }
    }
    我在Tran类中,调用了Class1中的TranDemo函数,那么我想保证Tran类中的TranDemo函数的完整
    性,该怎样处理?
      

  7.   

    1、Tran必须继承自ServicedComponent并加上必须的属性
    2、方法前必须加[AutoComplete]属性(或者手动设置提交方式)[Transaction(TransactionOption.Required)]
    [GuidAttribute("64615930-342c-4183-9ca4-8ae1589ebc51")]
    public class Tran : ServicedComponent
    {
                      [AutoComplete]
    public bool TranDemo()
    {
    SqlConnection conn = new SqlConnection("server = wfw;User id = sa; password =centaurus;database=Northwind");
    conn.Open(); SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;

    try
    {
    Class1 c=new Class1();
    c.TranDemo();
    cmd.CommandText = "update Products set unitPrice =  105 where ProductID =1";
    cmd.ExecuteNonQuery();
    return true; }
    catch (Exception e)
    {
    return false;
    } }
    }
      

  8.   

    qimini(循序渐进) :
    在多层架构的程序开发中,Com+服务组件我该放到那一层
    我的程序分为:
    客户层,业务外观层,业务逻辑层,数据访问层,数据实体层
      

  9.   

    注意:需要引用System.EnterpriseServices.dll
    using System.EnterpriseServices;
    using System.Runtime.InteropServices;更详细的内容,请参见这里:http://www.microsoft.com/china/MSDN/library/default.mspx
      

  10.   

    http://www.microsoft.com/china/MSDN/library/enterprisedevelopment/builddistapp/TransactionControl.mspx
      

  11.   

    能告诉我放在业务逻辑层的原因吗?
    另外,数据访问层还需要数据库的事务吗?
    Com+事务对性能到底影响有多大?
      

  12.   

    能交个朋友吗?qimini(循序渐进) 谢谢你把你的联系方式,qq发给我好吧