VBdotnet2005
asked on
using & try catch
Can I use Try Catch inside Using statement to report if errors?
Using ...
Using...
try
Catch
'to report erro
End try
End using
End using
Using ...
Using...
try
Catch
'to report erro
End try
End using
End using
yes you can.
Actually using block is something like this
Dim resource As New resourceType
Try
' Insert code to work with resource.
'here you can add whatever you want including extra try catch block
Finally
If resource IsNot Nothing Then
resource.Dispose()
End If
End Try
Actually using block is something like this
Dim resource As New resourceType
Try
' Insert code to work with resource.
'here you can add whatever you want including extra try catch block
Finally
If resource IsNot Nothing Then
resource.Dispose()
End If
End Try
ASKER
Can I also do this? I want to send any error to myself.
Try
using con as new sqlconnection..
'my other code
end using
Catch
'code to report error
End Try
Try
using con as new sqlconnection..
'my other code
end using
Catch
'code to report error
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you
Thanks from me as well Narman. I obviously learned something here..
Nope. That's an executable statement so it has to be in the body of a procedure.