Я пытаюсь получить значение IsAdmin с помощью SQL-запроса (этот запрос возвращает 1 строку или 0). но я получаю эту ошибку {"недопустимое чтение Предположительно нет никаких данных."}
Это мой код
public static bool Login (string iduser, string password, bool IsAdmin)
{
bool auth = false;
string query = string.Format("Select IsAdmin from [user] where iduser = '{0}' AND mdp = '{1}' ;", iduser, password);
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
SqlDataReader re = cmd.ExecuteReader();
auth = re.HasRows;
if (auth) { IsAdmin = re.GetBoolean(0); } // the error is on this line (this line will alow me to get IsAdmin Value If the user exist)
con.Close();
return auth;
}