473,398 Members | 2,343 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,398 software developers and data experts.

Not all code paths return a value

Hi,
I am srinivas, i am getting error like:Not all code paths return a value
I wrote 2 functions in a class which returns DataTable. after completion of 1 st function I got the currect result. whn I started writing 2 nd func I am getting this error, how can I eliminate this error.

Thanks in advance...
Jun 21 '07 #1
3 1227
pbmods
5,821 Expert 4TB
Heya, srinivas. Welcome to TSDN!

You're getting this warning because you have a conditional somewhere in your [typed] function that could cause the function to terminate without returning a value.

What language are you coding in?
Jun 21 '07 #2
Using Try Catch Block

But in Catch you wont catch and display the exception message. In Catch u throw the exception. I too got this warning i think its not error, am i right. In Function we return some values thats why we wont catch the exception.

wrtie this code
try

your code

catch
Throw ex // important

end try
Hi,
I am srinivas, i am getting error like:Not all code paths return a value
I wrote 2 functions in a class which returns DataTable. after completion of 1 st function I got the currect result. whn I started writing 2 nd func I am getting this error, how can I eliminate this error.

Thanks in advance...
Dec 1 '07 #3
Newbie19
123 100+
I read this post to try and solve why I get this error message, but it didn't work.

Can any one help/advise me? Here is the function that causes the error:

public String getOnTimeNames()
{
try
{
String mConn = "Data Source = San-SQL; Initial Catalog = OnTimeTesting; Integrated Security = True; Max Pool Size = 500";
String tSQL = "SELECT dbo.Defects.DefectId AS OnTimeID, dbo.Defects.Name AS Name FROM dbo.Defects INNER JOIN dbo.Projects ON dbo.Defects.ProjectId = dbo.Projects.ProjectId WHERE (dbo.Projects.ParentId = 126) ORDER BY dbo.Defects.DefectId DESC";
SqlConnection wConn = new SqlConnection(mConn);
SqlCommand mCmd = new SqlCommand(tSQL, wConn);
wConn.Open();
//readers for the data
SqlDataReader Reader = mCmd.ExecuteReader();
while (Reader.Read())
{

OnTime_Name = (String)Reader["Name"];

return OnTime_Name;


}
wConn.Close();
}
catch(ArgumentException )
{
return "An error occured whilst processing your request. Details follow: " ;
}


}
Thanks,

Newbie19
Jan 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
5
by: n_o_s_p_a__m | last post by:
Can't compile. Does this mean that all functions that throw exceptions must be of return type void? examples: // won't compile: "not all code paths return a value" public override int Run() {...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
4
by: OutdoorGuy | last post by:
Greetings, I am attempting to compile the code below, but I am receiving an error message when I do so. The error message is: "CSO161: 'Forloop.CalcAvg(int)': Not all code paths return a...
7
by: Robert | last post by:
I have the function below. it returns a "simpleresult" which I've also included the definition of below. In VS2005 (after upgrading the project), I get a warning indicating that Function...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.