views:

835

answers:

1

I have a WinForms application that interacts with a SqlCe local database. I manage db operations using BindingSources, TableAdapters and typed datasets.I have several operations scattered through several methods in two different classes that I need to perform in a transaction and I was thinking of using System.Transactions.Transaction or CommitableTransaction. My question is, would Transaction or CommittableTransaction work successfully in a transaction and rollback in an error in this example code or do I have to also use transaction in OtherClass methods too?:

OtherClass othercls = new OtherClass();  
...  

private void DoAll()  
{  
/* begin transaction here */
this.tableAdapter.DoSomeDBWork();  
othercls.DeleteSomeRecords(); //uses tableadapter+sql code to delete. throws exception on error. doesn't have transaction  
othercls.DeletOtherRecords(); //uses tableAdapter.Rows.Find(id).Delete(). throws exception on error. doesn't have transaction  
othercls.Update(); //uses tableadapter.Update(). throws exception on error. doesn't have transaction  
this.DeleteSomeFiles(); //throws exception on fail 
/* end transaction here */ 
}
+1  A: 
Sung Meister