You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

If using code that potentially can fail from time to time it is possible to use a Try Catch-statement and programmatically handle the error as opposed to having the application error out. Syntax for Try/Catch statement:     Try          // Commands to try to execute    End Try    Catch         // Commands to execute when an error occurs    End Catch
Example:
TRY     // Try the commands between this line and End Try    IMPORT [budget]=excelfile.{select * from [c:\budget\custombudgetfile.xlsx]}   // Import budget from file that may be edited by people in the organizationEND TRYCATCH  // If the try fails the commands in this catch block will be executed    PRINT 'An error occurred loading the custom budget file - will default to loading the audited budget file'    IMPORT [budget]=excelfile.{select * from [c:\budget\auditedbudgetfile.xlsx]}  // Load the budget file that we knowEND CATCH

  • No labels