有3个函数 ,
像事务一样。要不全执行行。如果有一个失败,全不执行。
我不光是对数据库操做。
如果对数据库操作还好说一些。。(sql的事务).net里有没有封装好的东东可以用?
我找了一下。没有找到结果。
只能自己写回滚的操作吗?请指点

解决方案 »

  1.   

    to 只能自己写回滚的操作吗?Automatic Undo/Redo for .NET classes
    http://www.codeproject.com/csharp/autoundoredo.asp或许对你有帮助
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.EnterpriseServices;namespace ClassLibrary1
    {
        
        [Transaction(TransactionOption.Required)]     public class Class2:ServicedComponent
        {
            public  Class2()
            { }
            public int Add(int a, int b)
            {
               
                return a + b;
            }
            public int Add1(int a, int b)
            {
                System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c1111:\12.txt",true);
                sw.WriteLine("-----------------");
                sw.Close();
                return a + b;
            }        [AutoComplete(true)]   
            public void U()
            {
                try
                {
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\1.txt", true);
                    sw.WriteLine("+++++++++++++");
                    sw.Close();
                    sw = new System.IO.StreamWriter(@"c1111:\12.txt", true);
                    sw.WriteLine("-----------------");
                    sw.Close();
                    
                    ContextUtil.SetComplete();
                }
                catch (Exception e)
                {
                    ContextUtil.SetAbort();                
                }
                finally
                {            }        }
        }
    }
      

  3.   

    这是COM+的回滚操作。
    可是我这做个小程序。可是并没有回滚。
    请指点下。
    谢谢啦。
      

  4.   

    比如你,要写2个文件,一个数据库表
    对应函数
    FileWriter1(),FileWriter2(),DbUpdate1(); 是这样吗如果是我的博客 http://www.cnblogs.com/flashelf/ 自己找去