using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { }
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; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)