using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { SqlCommand command1 = new SqlCommand("INSERT INTO Table1 (Column1) VALUES (@value)", connection, transaction); command1.Parameters.AddWithValue("@value", "Value1"); command1.ExecuteNonQuery(); SqlCommand command2 = new SqlCommand("INSERT INTO Table2 (Column1) VALUES (@value)", connection, transaction); command2.Parameters.AddWithValue("@value", "Value2"); command2.ExecuteNonQuery(); // Commit the transaction if all statements are executed successfully transaction.Commit(); Console.WriteLine("Transaction committed."); } catch (Exception ex) { // Rollback the transaction if any errors occur transaction.Rollback(); Console.WriteLine("Transaction rolled back."); } }In this example, we create a SqlConnection and open a database transaction using BeginTransaction(). We then execute two SqlCommands to insert data into two tables. If no exceptions are thrown, we commit the transaction. If any errors occur, we rollback the transaction. Packages that provide Transaction management capabilities in C# include System.Data.SqlClient, NHibernate, and Entity Framework.