Hi Everybody,
I'm sorry if the asnwer is already posted somewhere, I was not able to find it.
When I build my solution, I get the following error:
'UserManager.AuthenticateUser(string, string)': not all code paths return a value.
Dont know the reason why is this happening. But I have included my code underneath.
Any help will be highly appreciated. Thaks :)
public static WebUser AuthenticateUser(string UserName, string Password)
{
//string userNameTXT = UserName;
//string passwordTXT = Password;
WebUser user = null;
//------------------------------------------------------
using (SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=DB_Rental; Integrated Security=True;"))
{
cn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = cn;
cmd.CommandText = "select empID from TB_credentials WHERE @UserName = userNameTXT and @Password=passwordTXT";
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@userNameTXT", user.UserName);
cmd.Parameters.AddWithValue("@passwordTXT", user.Password);
SqlDataReader reader;
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
return user;
}
}
}
}