using System;
using System.Data;
using System.Data.SqlClient;
using System.Transactions;
using System.Collections.Generic;
using System.Text;

namespace ExplicitTransaction
{
   class Program
   {
      static void Main(string[] args)
      {
         CommittableTransaction tx = new CommittableTransaction();

         SqlConnection conn = new SqlConnection(
           "data source=localhost; initial catalog=SampleDB;integrated security=SSPI;");
         conn.Open();

         SqlCommand updateCommand = conn.CreateCommand();
         updateCommand.CommandText = "DELETE Customers WHERE ID > 3";

         conn.EnlistTransaction(tx);

         updateCommand.ExecuteNonQuery();

         tx.Rollback();

         conn.Close();
         Console.ReadLine();
      }
   }
}
