I am getting an error, I cannot return a value from the function below. Help will be appreciated.
private void UserExiest(string username)
{
SqlConnection myConnection = new SqlConnection("user id=test;" +
"password=test;" +
"server=.;" +
"Trusted_Connection=yes;" +
"database=DB; " +
"MultipleActiveResultSets=True;" +
"connection timeout=30");
myConnection.Open();
SqlCommand CHECKNPC = new SqlCommand("select struserid from USERDATA where strUserId = '" + username + "'", myConnection);
SqlDataReader NpcReader = CHECKNPC.ExecuteReader();
if (NpcReader.HasRows)
{
return "1";
}
else
{
return "0";
}
myConnection.Close();
}
private int UserExiestreturn NPCReader.HasRowsexistinstead ofexiestso i would also change the method name. It would hurt my eyes otherwise all the time if I were you.