Good Morning All,
I have code similar to the following
try{
using(var tx = new TransactionScope()){
var Xupdated = someDao.DoSomeUpdateQuery(); //this dao uses MS Data ApplicationBlock
var Yupdated = someDao.DoSomeOtherUpdateQuery(); //this dao also uses MS Data ApplicationBlock
if(Xupdated && Yupdated)
{
tx.Complete();
}
}
} catch(Exception ex){
DoSomethingWithTheException();
}
The dao methods have code like this
try{
var db = DatabaseFactory.CreateDatabase();
var cmd = db.GetStoredProcCommand(someSP);
var retVal = db.ExecuteNonQuery(cmd);
return (retVal > 0);
} catch (SqlException ex){
CustomException custom = new CustomException(ex.Message, ex);
throw custom;
}
The problem here is when 'Yupdated' returns false, I want 'DoSomeUpdateQuery()' to be rolled back. Unfortunately, 'DoSomeUpdateQuery()' changes are committed. How can i remedy this? I put a breakpoint in and tx.Complete() is never called. Does anyone know how I can get the appropriate desired behavior here? Thanks in advance for any pointers.
Cheers,
~ck in San Diego