Use SqlTransaction Object in the beginning of Connection open
and pass that transaction object in each SqlCommand object.
And by using Commit() or Rollback() Method you can decide the whether to save the changes or not.
using (var Conn = new SqlConnection(_ConnectionString))
{
SqlTransaction trans = null;
try
{
Conn.Open();
trans = Conn.BeginTransaction();
using (SqlCommand Com = new SqlCommand(ComText, Conn, trans))
{
}
trans.Commit();
}
catch (Exception Ex)
{
if (trans != null) trans.Rollback();
return -1;
}
}