try catch finally

Discussion in 'ASP .Net' started by hansiman, Jul 14, 2005.

  1. hansiman

    hansiman Guest

    function x
    something db

    catch ex as exception
    return "error"

    close db

    end try

    return value fetched from db

    end function

    Will the code in the finally run on error?
    hansiman, Jul 14, 2005
    1. Advertisements

  2. hansiman

    Razak Guest

    Razak, Jul 14, 2005
    1. Advertisements

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


    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    The sun never sets on
    the Kingdom of Heaven
    Kevin Spencer, Jul 14, 2005
  4. hansiman

    Sean M Guest

    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.
    Sean M, Jul 14, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.