Correct error handling in DAL

B

BigStef

Hi people,
I've been struggling over the past weeks to get rid of my old VB6
habits of using error handling everywhere and I think I'm catching up
quite fast!
I have a question though... I have read many Best Practices topics
about error handling and I trie not to create derived Exception errors
to have Application specifics error since the framework covers a great
deal of possible exceptions that may occur.
So here is my question:
I have a DAL class library with a class that uses Enterprise Libraries
Data app blocks. In one of the methods I have defined in there, one is
executing a stored procedure that returns a list of rows which I store
in a dataset. Then, I want to check in the dataset if there are tables
in it, which would tell me that data have actually been returned. Now,
I have tried to have the SP return nothing which makes my DataSet
tables count to 1 but this table has 0 rows. What I want to do is, in
the case that no tables OR an empty table would be returned, I'd like
to throw an exception which would be handled in my client's try catch
but I do not want to use this: throw new Exception(...) since using
Exception, ApplicationException or Systemexception is not
recommended... What would be the best way to handle this situation?
Maybe I am complicating myself?
All I want is to raise some kind of notification without having to have
if statements that checks for a flag old vb6-style.
If my question isn't quite clear, feel free to ask for more precisions!

Thanks a lot in advance!

Regards,

BigStef
 
W

William \(Bill\) Vaughn

If you want to raise an event or exception in a client application, trap the
InfoMessage event and or execute a RAISERROR in the SP. Again, this is
detailed in my book.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 

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