1

SqlCe 로컬 데이터베이스와 상호 작용하는 WinForms 응용 프로그램이 있습니다. BindingSources, TableAdapters 및 유형이 지정된 데이터 집합을 사용하여 db 작업을 관리합니다. 트랜잭션에서 수행해야하는 두 가지 클래스의 여러 메서드를 통해 분산 된 여러 작업이 있으며 System.Transactions.Transaction 또는 CommitableTransaction을 사용하려고합니다. 내 질문은, 것 트랜잭션 또는이 예제 코드에서 오류가 트랜잭션과 롤백에 성공적으로 CommittableTransaction 작업 또는 나 또한 너무 OtherClass 방법에서 트랜잭션을 사용하는?형식화 된 데이터 집합 및 SQL Server CE와의 트랜잭션

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

하는 System.Transactions를 시도해야합니까 . TransactionScope. 예외가 트랜잭션의 범위 내에서 발생할 경우 System.Transaction.TransactionScope Remark 부에 따르면

,

는 트랜잭션이되는 것이 다시 압연 참여한다.

관련 문제