473,396 Members | 1,827 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,396 software developers and data experts.

using custom exceptions when DAL return no rows

Hey

..NET 2.0

I'm developing an application (n-tier, data acces layer (DAL), bizlayer and
presentation layer)

If for example in the DAL a stored procedure call returns no rows then I
want an exception to be thrown. So I created an custom exception called
NoRowsException and throws it.

When I tryed this the app terminated unexpectedly, because in the try /
catch block I didn't test if the exception was NoRowsException.. I had
Exception there and thought Exception took all Exceptions, but it didn't...
so it looks like I also have to test if it's an NoRowsException:
try
{
//todo
}
catch (NoRowsException norows) {}
catch (Exception exp)

any thoughts about this? could this be done in a better way?
Dec 6 '07 #1
2 1734
Granted, getting feedback from the RDBMS is a little tougher than just
DotNet code....

But here is a great resource:
http://blogs.msdn.com/kcwalina/archi...16/396787.aspx
:"exceptions should be exceptional"...thus if you expect to have no rows
......then its probably not exceptional, and you should code to handle zero
row.

if it is exceptional....like the GUI came up with a list of employees...and
while you're looking at that screen.....somebody deletes the employee..and
you go to edit JohnSmith...you get zero rows...then that would be
exceptional.


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:ua**************@TK2MSFTNGP02.phx.gbl...
Hey

.NET 2.0

I'm developing an application (n-tier, data acces layer (DAL), bizlayer
and presentation layer)

If for example in the DAL a stored procedure call returns no rows then I
want an exception to be thrown. So I created an custom exception called
NoRowsException and throws it.

When I tryed this the app terminated unexpectedly, because in the try /
catch block I didn't test if the exception was NoRowsException.. I had
Exception there and thought Exception took all Exceptions, but it
didn't... so it looks like I also have to test if it's an NoRowsException:
try
{
//todo
}
catch (NoRowsException norows) {}
catch (Exception exp)

any thoughts about this? could this be done in a better way?

Dec 6 '07 #2
Jeff wrote:
I'm developing an application (n-tier, data acces layer (DAL), bizlayer and
presentation layer)
3-layer not n-tier.
If for example in the DAL a stored procedure call returns no rows then I
want an exception to be thrown. So I created an custom exception called
NoRowsException and throws it.

When I tryed this the app terminated unexpectedly, because in the try /
catch block I didn't test if the exception was NoRowsException.. I had
Exception there and thought Exception took all Exceptions, but it didn't...
It should.

Could you post an small simple example showing the problem ?

Arne
Dec 7 '07 #3

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

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
6
by: Flare | last post by:
Hi i just read: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp Wich is interesting reading by the way. But. I have'nt used exception very much to...
1
by: Wm. Scott Miller | last post by:
I have a Custom DTS Task for SQL Server and I've got it working fine, except for when I try to access its properties from an ActiveX script. I have added a new property called Length and a method...
12
by: bj7lewis | last post by:
I am working on a project I want to add a few files as resource to access(copy them to FS and use) at runtime. So far in VS.NET IDE, I Add Files to the project and set its Build Action to...
40
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
0
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
2
by: | last post by:
I am using a datareader to cycle through a list of records one at a time. I frequently get connection timeouts and am wondering what I am doing wrong. In more detail, I retrieve an excel...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.