Throwing exceptions

G

Guest

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.
 
K

Kevin Spencer

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.
 
E

Eliyahu Goldin

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top