I have read plenty articles on Bool methods that have problems returning a value and i have been having the same problem except I cant see anyway around mine.
public bool GetAdministrators(string userName, string password)
{
SqlConnection conn = new SqlConnection("Data Source=(local); database=ManagementNAV; Integrated Security=True");
SqlCommand cmd = new SqlCommand("GetAdministrators", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (reader["userName"].ToString() == userName && reader["password"].ToString() == password)
{
return true;
}
}
reader.Close();
I have tried to use a static bool method but i still receive the same problem, And i have created a bool variable which i assigned to true once the if statement was found as true, which was retuned once the while loop was executed but it came with the error that the bool varible was not assigned
Thank you for any advice in advance