原创  事务测试 收藏

在不改变现有代码的基础上增加事务

缺点 消耗系统资源比较大,响应比较慢.

static public void testTran()
  {
   ServiceConfig sc = new ServiceConfig();
   sc.Transaction = TransactionOption.Required;
   sc.TrackingEnabled = true;
   ServiceDomain.Enter(sc);
   try
   {     
    Insert("1"); 
    Insert("a"); 
    ContextUtil.SetComplete();
   }
   catch (System.Exception except)
   {
    HttpContext.Current.Response.Write(except.ToString());
    ContextUtil.SetAbort();
    
   }
   finally
   {
    ServiceDomain.Leave();
   }
  
  }
  


 static public void Insert(string val)
  {
   string sql="insert into test1 (number) values ('"+ val  +"') ";

   DBClass.SqlHelper.ExecuteDataset(DBClass.SqlHelper.CONNSTR,CommandType.Text,sql);
  
  } 

发表于 @ 2008年03月03日 10:42:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:对话AJAX框架双杰 | 新一篇:在IE中像迅雷那样通过右击链接打开程序

  • 发表评论
  • 评论内容:
  •  
Copyright © ayun00
Powered by CSDN Blog