try catch finally

H

hansiman

function x
try
something db

catch ex as exception
return "error"

finally
close db

end try

return value fetched from db

end function

Will the code in the finally run on error?
 
K

Kevin Spencer

It will run on error, and even if you put a Return statement into your
Function.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
S

Sean M

Code in the finally section of an exception block will run whether or not an
error occurs. This is a good place to close your opened resources like
database connections.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top