I implement function done by cshar return dataset but it display error and i don't know where is error
and how to solve this error please
function generate error
public DataSet UnlockUser(string szLoginName, string strHost)
{
DataSet objDS = new DataSet();
string strEnv = "";
try
{
objDS = _ISecurityService.GetEnv(szLoginName.Trim());
if (objDS.Tables[0].Rows.Count > 0)
{
strEnv = objDS.Tables[0].Rows[0][0].ToString();
if (strEnv.Trim() == "PY" || strEnv.Trim() == "PD")
{
if (_ISecurityService.ChangeFailedLoginAttempts(szLoginName, 0) > 0)
{
if (_ISecurityService.AuditLoginAttempts(szLoginName, strHost, "S", objDS.Tables[0].Rows[0][0].ToString(), "Account is Unlocked", "Unlock") > 0)
{
return _ISecurityService.FillRtnDs("0", " User - " + szLoginName.Trim() + " is Unlocked Successfully");
}
else
{
return _ISecurityService.FillRtnDs("E9", "Failed to Unlock, Please try again");
}
}
}
else
{
return _ISecurityService.FillRtnDs("-4", "Invalid User with Different Env"); //Invalid User with Different Env
}
}
else
{
return _ISecurityService.FillRtnDs("-5", "Invalid User"); //Invalid User
}
}
catch (Exception ex)
{
return _ISecurityService.FillRtnDs("E9", ex.Message);
}
}
Sam HobbsPosted Jun 12, 2023, 2:59 PM
There is no return statement at the end. The method will do an automatic return at the end of the method but it does not know what to return. Sometimes we know (or think we are sure) that the method will never execute an automatic return but the compiler does not know that.
Rajanikant HawaldarPosted Jun 11, 2023, 10:28 AM
do not add else part to first if condition instead just return whatever your going to return in else part