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

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

there is no return value when designation does not equal student


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


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

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