473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Throwing exceptions

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.
Jun 26 '06 #1
4 1216
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" <Sr*****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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.

Jun 26 '06 #2
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" <Sr*****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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.

Jun 26 '06 #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" <Sr*****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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.


Jun 26 '06 #4
:-)

"Arne Garvander" <Ar***********@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
Kevin,
I love your title.

Jun 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the...
21
by: mihai | last post by:
People say that is a bad technique to throw exception from constructors; and that the solution would be to create a function _create_ to initialize an object. What about copy constructors? How...
1
by: Farooq Khan | last post by:
i'm writing a class library having following code snippet. i want this class to report an error (by throwing an Exception) to the application using this class library. the problem is that within...
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
40
by: Sek | last post by:
Is it appropriate to throw exception from a constructor? Thats the only way i could think of to denote the failure of constructor, wherein i am invoking couple of other classes to initialise the...
6
by: Marvin Barley | last post by:
I have a class that throws exceptions in new initializer, and a static array of objects of this type. When something is wrong in initialization, CGI program crashes miserably. Debugging shows...
1
by: usenet | last post by:
I wrote some sample code (see below) for nested exception throwing i.e. my catch blocks are throwing exceptions of their own (for simplicity I used standard exceptions). I am getting some...
4
by: Jay Dee | last post by:
I have a query about throwing exceptions. To throw an exception I type something like: try { // do somthing } catch (ArgumentOutOfRangeException) {
3
balabaster
by: balabaster | last post by:
Hey all, this might seem somewhat remedial but I'm unable to find any documentation on it - it pertains to throwing exceptions within a DLL. I've written a DLL that contains a bunch of classes....
21
by: Chris M. Thomasson | last post by:
Is it every appropriate to throw in a dtor? I am thinking about a simple example of a wrapper around a POSIX file... ________________________________________________________________________ class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.