473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Exception Management

I have an asp .net application where a user can click a button to
retrieve certain data.

The structure of the onClick handler is as follows:

Protected Sub button_click(blah blah)
Try
run some queries
call FindSomeData()
display confirmation message
Catch ex Ass Exception
display error 1
End Try
End Sub

Private Sub FindSomeData(ByVal key as integer, ByRef returnVal As
String, ByRef returnKey As Int)
Try
run a query
massage the data
Catch ex Ass Exception
display error 2
End Try
End Sub

If an exception were raised in FindSomeData, I would except the "display
error 2" to execute and the page to stop executing. However, what
happens is that "display error 2" is executed, but control returns to
the onclick sub and the confirmation message is also displayed..

Is this expected functionaility? How can i get the page to display error
2 and then stop execution?

Thanks in advance.

Bijoy

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 1011
When you catch an Exception, you do exactly that: catch it. It no longer
stops execution, but instead does what your Exception Handler says to do. If
you want it to cause the Page to stop execution, throw it in your Catch
block. Example:

Try
...
Catch ex As Exception
...
Throw ex
End Try

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Bijoy Naick" <b_*****@donoteamil.yahoo.ca> wrote in message
news:O6**************@TK2MSFTNGP10.phx.gbl...
I have an asp .net application where a user can click a button to
retrieve certain data.

The structure of the onClick handler is as follows:

Protected Sub button_click(blah blah)
Try
run some queries
call FindSomeData()
display confirmation message
Catch ex Ass Exception
display error 1
End Try
End Sub

Private Sub FindSomeData(ByVal key as integer, ByRef returnVal As
String, ByRef returnKey As Int)
Try
run a query
massage the data
Catch ex Ass Exception
display error 2
End Try
End Sub

If an exception were raised in FindSomeData, I would except the "display
error 2" to execute and the page to stop executing. However, what
happens is that "display error 2" is executed, but control returns to
the onclick sub and the confirmation message is also displayed..

Is this expected functionaility? How can i get the page to display error
2 and then stop execution?

Thanks in advance.

Bijoy

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
23s
I typically implement something like this: basically just turn FindSomeData
from a sub into a function that returns whether or not it threw an
exception.

Protected sub button_click(blah blah)

Try
run some queries
If FindSomeData() Then
display confirmation message
End If
Catch ex As Exception
display error 1
End Try

End Sub

Private FUNCTION FindSomeData(ByVal key as integer, ByRef returnVal As
String, ByRef returnKey As Int) as BOOLEAN

Try
run a query
massage the data
Return True
Catch ex As Exception
display error 2
Return False
End Try

End Sub

"Bijoy Naick" <b_*****@donoteamil.yahoo.ca> wrote in message
news:O6**************@TK2MSFTNGP10.phx.gbl...
I have an asp .net application where a user can click a button to
retrieve certain data.

The structure of the onClick handler is as follows:

Protected Sub button_click(blah blah)
Try
run some queries
call FindSomeData()
display confirmation message
Catch ex Ass Exception
display error 1
End Try
End Sub

Private Sub FindSomeData(ByVal key as integer, ByRef returnVal As
String, ByRef returnKey As Int)
Try
run a query
massage the data
Catch ex Ass Exception
display error 2
End Try
End Sub

If an exception were raised in FindSomeData, I would except the "display
error 2" to execute and the page to stop executing. However, what
happens is that "display error 2" is executed, but control returns to
the onclick sub and the confirmation message is also displayed..

Is this expected functionaility? How can i get the page to display error
2 and then stop execution?

Thanks in advance.

Bijoy

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Abelardo Vacca | last post by:
Hello, I am currently in the process of switching our application to a N-Tier model with .NET. One of the aspects we want ot get right from the start not to worry about it after is the...
5
by: PCC | last post by:
I am using the Exception Managment Application Block on Windows Server 2003 Enterprise and .NET v1.1. If I use the block with an ASP.NET web wervice or in a web application I get the following...
1
by: Abelardo Vacca | last post by:
Hello, I am currently in the process of switching our application to a N-Tier model with .NET. One of the aspects we want ot get right from the start not to worry about it after is the...
1
by: SQLJunkie | last post by:
Hi, I have installed SQL 2005 RTM on a new server and I keep getting this error (described below) quite frequently. Was wondering if anyone has a clue on what's happening here. I tried googling...
2
by: KaNos | last post by:
Hello world, I've made a webservice (c# v2) to install in a server IIS 6 on a Windows 2000 last SP. We can use the webservice in local, throw the pages wich present the methods, with a windows...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.