Connecting Tech Pros Worldwide Help | Site Map

Throwing exceptions

Sridhar
Guest
 
Posts: n/a
#1: Jun 26 '06
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
Guest
 
Posts: n/a
#2: Jun 26 '06

re: Throwing exceptions


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" <Sridhar@discussions.microsoft.com> wrote in message
news:46117C2B-D4C4-4A3D-B775-CB58FA719BD5@microsoft.com...[color=blue]
> 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.[/color]


Eliyahu Goldin
Guest
 
Posts: n/a
#3: Jun 26 '06

re: Throwing exceptions


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" <Sridhar@discussions.microsoft.com> wrote in message
news:46117C2B-D4C4-4A3D-B775-CB58FA719BD5@microsoft.com...[color=blue]
> 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.[/color]


Arne Garvander
Guest
 
Posts: n/a
#4: Jun 26 '06

re: Throwing exceptions


Kevin,
I love your title.

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


"Kevin Spencer" wrote:
[color=blue]
> 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" <Sridhar@discussions.microsoft.com> wrote in message
> news:46117C2B-D4C4-4A3D-B775-CB58FA719BD5@microsoft.com...[color=green]
> > 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.[/color]
>
>
>[/color]
Kevin Spencer
Guest
 
Posts: n/a
#5: Jun 26 '06

re: Throwing exceptions


:-)

"Arne Garvander" <ArneGarvander@discussions.microsoft.com> wrote in message
news:1A0D400B-A29D-4686-A817-34A80047614B@microsoft.com...[color=blue]
> Kevin,
> I love your title.[/color]


Closed Thread