a basic question on using DAAB ? plz guide and help me

Topics: Data Access Application Block
Feb 1, 2010 at 2:18 PM


thanks for your attention and time.

I am using DAAB to fill business objects (custom objects/ DTO) using IDataReader. Of course return type of function is custom object type.

Now there can be 3 possibilities (please just consider stored procedure will return only one record)

1) stored procedure return a record
2) stored procedure do not find a record
3) there accrue an error

Suppose function's return type is customer, if data found I will receive a object of  customer, if no record found I will get null but how to know on use interface if there would be some error ? I am using try catch blocks but in case of error what should be return to indicate on user interface that there was some error while fetching data from db ?

Please guide me.

thanks in anticipation for sharing and guding,


Feb 2, 2010 at 2:29 AM

Well, since you already have a try catch block, the obvious answer would be to display an error message indicating that there was an error while reading data from the database in the catch block.  This is more of an exception handling question rather than on DAAB.  I'm not sure if you're asking for the appropriate error message or how to handle sql exceptions or something I don't know.

Feel free to add information.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

Feb 2, 2010 at 3:10 AM

You are right I have used catch block but issue is that I do not want just a flat error page saying a parameter error.. or an error accured while calling stored procedure.

How I can return error message from here ? (function return type is customre object that DAAB is filling, If I got on user interface that there is some error that I can display message accordingly. But not gettng how to send this message back.

please advise.




Feb 2, 2010 at 3:36 AM

Catch an sql exception in your method that returns a customer object.  From there, determine what is the appropriate error message to display to the user and throw a different type of exception containing the error message you want.  In the user interface code, catch for that exception and display it to the user. 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.