try catch finally

  • Thread starter Thread starter hansiman
  • Start date Start date
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?
 
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
 
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

Back
Top