Click here to Skip to main content
15,033,219 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
            {
}




and

C#
using (IDbTransaction tran = conn.BeginTransaction())
   {
       try
       {
           // transactional code...
           using (SqlCommand cmd = conn.CreateCommand())
           {
               cmd.CommandText = "INSERT INTO Data(Code) VALUES('A-100');";
               cmd.Transaction = tran as SqlTransaction;
               cmd.ExecuteNonQuery();
           }
           tran.Commit();
       }
       catch(Exception ex)
       {
           tran.Rollback();
           throw;
       }
   }




hat is the difference between the above two
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900