G
Guest
How do I ensure that all database operations are rolled back when database
connectivity is lost during the middle of a transaction?
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction transaction = connection.BeginTransaction();
try
{
Insert1
Insert2
//// connection is lost here /////
Insert3
transaction.Commit();
}
catch
{
//Roll back the transaction.
transaction.Rollback();
}
}
Is this set at the database and/or is it different for Sql Server vs Oracle?
connectivity is lost during the middle of a transaction?
using (DbConnection connection = db.CreateConnection())
{
connection.Open();
DbTransaction transaction = connection.BeginTransaction();
try
{
Insert1
Insert2
//// connection is lost here /////
Insert3
transaction.Commit();
}
catch
{
//Roll back the transaction.
transaction.Rollback();
}
}
Is this set at the database and/or is it different for Sql Server vs Oracle?