Link to home
Create AccountLog in
Avatar of emi_sastra
emi_sastra

asked on

Error Handling.

Hi,

I have a windows application.
Loot at the scenario at code snippet.

When there is error once at Save_Detail, I want it stop the next process and goes through the exception of the caller which Save sub.

Thank you.




Private sub Save()
 
    Begin Transaction
 
    Try
    For Each dtRow as datarow in dttable.Rows
          Save_Detail dtRow
    Next 
 
    Commit Transation
 
    Catch ex as exception
        Rollback Transation.
        msgbox ...
 
    End Try
 
End Sub
 
private sub  Save_Detail (dtRow)
 
    Try
       saving data ...
    Catch ex as exception
        msgbox ...
    End Try  
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Having a little trouble understanding...When you experience and error in the Private Sub Save_Detail, you want it to stop and do the Rollback Transaction?

Such as:

private sub  Save_Detail (dtRow)
 
    Try
       saving data ...
    Catch ex as exception
        Rollback Transaction.
        msgbox ...
    End Try  
 
End Sub

I don't think I understand correctly.


Looks like appari underatood...he is afterall the WIZARD!  I learned a little somethig too.
Avatar of emi_sastra
emi_sastra

ASKER

Hi appari,

It works.

Thank you very much for your help.
Hi rgn2121,

Yes, we all are going to learn and learn.

Thank you for your help.