locked
a basic question on using DAAB ? Please guide RRS feed

  • Question

  • User852864959 posted

    Hi,

    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 function will return me a 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,

    Haansi

    <input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

    Monday, February 1, 2010 9:17 AM

Answers

  • User1754323106 posted

    what you can do is

    1. If successful, then always return a non-null customer object. If no record found, returns a null object

    2. throw an exception in the catch statement as in "throw ex" and have your business layer catch the exception and return a user friendly error message.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 1, 2010 10:50 AM

All replies

  • User1754323106 posted

    what you can do is

    1. If successful, then always return a non-null customer object. If no record found, returns a null object

    2. throw an exception in the catch statement as in "throw ex" and have your business layer catch the exception and return a user friendly error message.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 1, 2010 10:50 AM
  • User852864959 posted

    Thanks for guding,


    what you can do is

    1. If successful, then always return a non-null customer object. If no record found, returns a null object

    I am already doing 1.

    2. throw an exception in the catch statement as in "throw ex" and have your business layer catch the exception and return a user friendly error message.

    Regarding 2 will my catch box return message to user interface ? I want to display a user firendly message on user end but not getting how I will catch error message on aspx page ?

    In BLL function's return type is customer object, to get object or error message I will have a object of customer type. How I will handle if BLL throws an error.

    Please explain & guide.

    Monday, February 1, 2010 10:27 PM
  • User-37275327 posted

    If you want to throw DAL exception to BLL, try this

    In DAL

    try

       dosomething()

    Catch(Exception ex)

     throw

    End try


    in your BLL

    try


    catch(Exception ex)

     msgbox (ex.tostring)

    end try

    DAL exception will throw to BLL layer


    Wednesday, February 10, 2010 12:32 PM