Mega Code Archive

 
Categories / C# Tutorial / ADO Net
 

Implicit Transaction

using System; using System.Data; using System.Data.SqlClient; using System.Transactions; using System.Collections.Generic; using System.Text;     class Program     {         static void Main(string[] args)         {             using (TransactionScope scope = new TransactionScope())             {                 using (SqlConnection conn = new SqlConnection("data source=localhost; initial catalog=SampleDB; Integrated Security=SSPI;"))                 {                     conn.Open();                     SqlCommand cmd = conn.CreateCommand();                     cmd.CommandText = "DELETE Employees";                     cmd.ExecuteNonQuery();                     int y = 1;                     y -= 1;                     Console.WriteLine("{0}", 1 / y);                                      }                 scope.Complete();             }         }     }