try/catch error

T

tshad

Why am I getting this error:

*************************************************************
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30616: Variable 'exc' hides a variable in an
enclosing block.

Source Error:

Line 340: Try
Line 341: dbReader = myDbObject.RunProcedure("AddNewHire", parameters)
Line 342: Catch exc as exception
Line 343: ErrorMessage.Text = "Unable to add new hire at this time"
Line 344: Finally
***********************************************************************

Sub SubmitNewHire_Click(s as Object, e as ImageClickEventArgs)
Dim exc as Integer
....
Try
dbReader = myDbObject.RunProcedure("AddNewHire", parameters)
Catch exc as exception
ErrorMessage.Text = "Unable to add new hire at this time"
Finally
dbReader.Close()
End Try
....
End Sub

What is "exc" hiding?

Thanks,

Tom
 
R

Ray Holiday

Your "catch" is not catching your variable but a System.Exception object

You declare exc has an Integer "Dim exc as Integer", then you're trying to
Catch an exception with the same name.

Just use a different name for your exception like:
"Catch ex1 as exception"
 

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