2009-08-13 5 views
0

에 대한 간단한 질문의 경우처럼 코드 조회 : 그것은 캐치로 전환하는 경우InsertOnSubmit

dim db = new context.mytable 
db.somefield = something 
context.insertonsubmit(db) 
try 
    context.save 
catch ex as exception 
    ''----???? 
end try 

는 어떻게 상황에서 DB를 제거하는?

답변

0

하나 개의 아이디어는 시도 캐치의 전체 프로세스를 포장하는, 그래서 것 예외가 발생하면 상황에 맞는 배치하여 객체가 더 이상 맥락에서이다, 뭔가 같은 가져옵니다.

try 
    dim context = new //LINQ-To-SQL context 
    dim db = new context.mytable 
    db.somefield = something 
    context.insertonsubmit(db) 
    context.save 
catch ex as exception 
    context.dispose(); 
end try 

주 : 나는 당신이 그것을 시험해야 할 것이기 때문에 이것을 시도하지 않았다.

관련 문제