Throwing exceptions

Discussion in 'ASP .Net' started by =?Utf-8?B?U3JpZGhhcg==?=, Jun 26, 2006.

  1. Hi,

    I would like to know the general procedure to throw exceptions. Lets say
    I have a datagrid in my webpage and I am pulling the data for my webpage
    using a function. The function accepts parameter CompanyId and returns
    datatable. If I pass an empty CompanyId from the webpage, the function
    should throw an exception saying "CompanyId is empty". If I pass a Valid
    CompanyId, it should return datatable. So how can we return multiple data
    typed values from the same function?

    Please let me know.

    Thanks,
    Sridhar.
    =?Utf-8?B?U3JpZGhhcg==?=, Jun 26, 2006
    #1
    1. Advertising

  2. Throwing exceptions stops execution. So, if you throw an exception, the
    exception is not "returned" from the method, but "thrown" by it. Therefore,
    when an exception is thrown, nothing is returned from the method. The method
    simply doesn't return.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    Professional Chicken Salad Alchemist

    Big thicks are made up of lots of little thins.


    "Sridhar" <> wrote in message
    news:...
    > Hi,
    >
    > I would like to know the general procedure to throw exceptions. Lets say
    > I have a datagrid in my webpage and I am pulling the data for my webpage
    > using a function. The function accepts parameter CompanyId and returns
    > datatable. If I pass an empty CompanyId from the webpage, the function
    > should throw an exception saying "CompanyId is empty". If I pass a Valid
    > CompanyId, it should return datatable. So how can we return multiple data
    > typed values from the same function?
    >
    > Please let me know.
    >
    > Thanks,
    > Sridhar.
    Kevin Spencer, Jun 26, 2006
    #2
    1. Advertising

  3. Kevin,
    I love your title.

    --
    Arne Garvander
    (I program VB.Net for fun and C# to get paid.)


    "Kevin Spencer" wrote:

    > Throwing exceptions stops execution. So, if you throw an exception, the
    > exception is not "returned" from the method, but "thrown" by it. Therefore,
    > when an exception is thrown, nothing is returned from the method. The method
    > simply doesn't return.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > Professional Chicken Salad Alchemist
    >
    > Big thicks are made up of lots of little thins.
    >
    >
    > "Sridhar" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I would like to know the general procedure to throw exceptions. Lets say
    > > I have a datagrid in my webpage and I am pulling the data for my webpage
    > > using a function. The function accepts parameter CompanyId and returns
    > > datatable. If I pass an empty CompanyId from the webpage, the function
    > > should throw an exception saying "CompanyId is empty". If I pass a Valid
    > > CompanyId, it should return datatable. So how can we return multiple data
    > > typed values from the same function?
    > >
    > > Please let me know.
    > >
    > > Thanks,
    > > Sridhar.

    >
    >
    >
    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Jun 26, 2006
    #3
  4. Sridhar,

    When you throw an exception inside your function, the function doesn't
    return a value in a regular way. The whole chain of the code execution
    breaks. The function won't finish and the next code to execute will be your
    catch block if you have any. If you don't, you will get a message about an
    unhandled exception.

    Eliyahu

    "Sridhar" <> wrote in message
    news:...
    > Hi,
    >
    > I would like to know the general procedure to throw exceptions. Lets say
    > I have a datagrid in my webpage and I am pulling the data for my webpage
    > using a function. The function accepts parameter CompanyId and returns
    > datatable. If I pass an empty CompanyId from the webpage, the function
    > should throw an exception saying "CompanyId is empty". If I pass a Valid
    > CompanyId, it should return datatable. So how can we return multiple data
    > typed values from the same function?
    >
    > Please let me know.
    >
    > Thanks,
    > Sridhar.
    Eliyahu Goldin, Jun 26, 2006
    #4
  5. :)

    "Arne Garvander" <> wrote in message
    news:...
    > Kevin,
    > I love your title.
    Kevin Spencer, Jun 26, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C

    Throwing Exceptions

    C, Nov 6, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    367
    Kevin Spencer
    Nov 6, 2003
  2. =?Utf-8?B?Q2xpdmU=?=

    Throwing Exceptions

    =?Utf-8?B?Q2xpdmU=?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    338
    S. Justin Gengo
    Feb 20, 2004
  3. Loic Minier
    Replies:
    1
    Views:
    2,063
    Loïc Minier
    Aug 19, 2003
  4. John Leonard
    Replies:
    7
    Views:
    340
  5. Replies:
    8
    Views:
    490
    Gordon Beaton
    Jan 3, 2006
Loading...

Share This Page