TransactionScope 事物

  public  void  UpdataMdiDt(DataTable[] dt, SqlDataAdapter[] dpt,  out  short  signErr,  out  string  strErr)
         {
             signErr = 1; strErr =  "" ;
             using  (TransactionScope ts =  new  TransactionScope())
             {
 
 
                 SqlConnection conn =  new  SqlConnection(constring);
                 conn.Open();
                 if  (signErr == 0)  return ;
                 try
                 {
                     SqlCommandBuilder[] scb =  new  SqlCommandBuilder[dt.Length];
 
                     for  ( int  i = 0; i < dt.Length; i++)
                     {
                         scb[i] =  new  SqlCommandBuilder(dpt[i]);
                         dpt[i].Update(dt[i]);
                     }
                     ts.Complete();
 
                 }
                 catch  (Exception ex)
                 {
                     signErr = 0;
                     strErr = ex.ToString();
                 }
             }
 
        

你可能感兴趣的:(transaction)