// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data.SqlClient; namespace E { public class Program { public static void Test() { using(SqlConnection con = new SqlConnection(@"Server=ARNEPC4\SQLEXPRESS;Integrated Security=SSPI;Database=Test")) { con.Open(); SqlTransaction tx = con.BeginTransaction(); SqlCommand cmd = new SqlCommand("INSERT INTO t1 VALUES(777,'ABC')", con); cmd.Transaction = tx; cmd.ExecuteNonQuery(); tx.Rollback(); } } public static void Main(string[] args) { Test(); } } }