1,105,333 Community Members

Error: not all code paths return a value, anyone give me solution for this

Member Avatar
raajsj
Newbie Poster
21 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
public string generateEmployeeid()*//here i am getting this error  'objdataclassname.generateEmployeeid()'.' not all code paths return a value'*
{       
objDataBaseClass = new DataBaseClass();
if (Designation == "Student")
{
int id;
int count = 01;
string typ = "SID-";
objDataBaseClass = new DataBaseClass();
Table = objDataBaseClass.GetDataTable("spGetEmployeeID");// passing storerprocedure name
if (Table.Rows.Count > 0)
{
DataRow Row = Table.Rows[0];
id = int.Parse(Row[0].ToString());
returnString = typ + (count + id).ToString();
}
return returnString;
} }  // i need to generate Userid for different users
Member Avatar
jstfsklh211
Junior Poster
155 posts since Apr 2011
Reputation Points: 38 [?]
Q&As Helped to Solve: 35 [?]
Skill Endorsements: 2 [?]
 
0
 

there is no return value when designation does not equal student

Member Avatar
ggamble
Junior Poster
151 posts since Mar 2006
Reputation Points: 1 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 4 [?]
 
0
 

You need a return value between the two curley brackets on line 18, like mentioned above.

Member Avatar
cyberdaemon
Junior Poster
125 posts since Nov 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

try to declare the returnString at the top of your code.. after the method.. and specify the datatype..

Question Answered as of 9 Months Ago by jstfsklh211, ggamble and cyberdaemon
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article