Catch error message

T

tshad

I am trying to do:
*************************************
Try
objCmd.ExecuteNonQuery()
Catch e As Exception
response.write("We have a message: " & e.Message & "<br>")
End Try
************************************************

And I get the 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 'e' hides a variable in an
enclosing block.

Source Error:

Line 51: Try
Line 52: objCmd.ExecuteNonQuery()
Line 53: Catch e As Exception
Line 54: response.write("We have a message: " & e.Message & "<br>")
Line 55: End Try
*********************************************************************************

What is this saying?

I got this from someone elses program and "e" doesn't seem to be defined
anywhere.

Thanks,

Tom.
 
S

Scott Lee

I would guess that you are using this Try/Catch block in an event handler.
The variable 'e' is probably the eventargs. Catch ex instead.

Scott Lee
(e-mail address removed)
 
G

Greg Burns

It is probably defined in the event procedure your code resides in, for
example:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Just change your code to:
Try
objCmd.ExecuteNonQuery()
Catch ex As Exception
response.write("We have a message: " & ex.Message & "<br>")
End Try

HTH,
Greg
 
T

tshad

That was it.

Thanks,

Tom

Greg Burns said:
It is probably defined in the event procedure your code resides in, for
example:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Just change your code to:


HTH,
Greg
 

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

Similar Threads

Error with server 3
Catch Error 2
catch{} butterfingers {} 1
Configuration Error Message 8
error message 2
Compiler Error Message: CS1595 6
Compiler Error Message 1
Incorrect Syntax Near... Error Message 1

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,269
Latest member
vinaykumar_nevatia23

Latest Threads

Top