Olá, como o método possui um retorno bool, falto você dar este retorno depois if, usando um simples else, segue o método abaixo corrigido:
public bool ValidaCPF(string cpf)
{
if (cpf != null)
{
OleDbCommand command = null;
string sql = "SELECT STUDIO_PAX_PILATES_CPF FROM CLIENTES WHERE STUDIO_PAX_PILATES_CPF = @cpf ORDER BY STUDIO_PAX_PILATES_CPF";
try
{
command = new OleDbCommand();
command.Connection = Connection;
command.CommandText = sql;
command.CommandType = CommandType.Text;
Connection.Open();
OleDbDataReader reader = command.ExecuteReader();
if (!reader.HasRows)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (Connection.State == ConnectionState.Open)
{
Connection.Close();
}
}
}
else
{
return false;
}
}
Vitor Mendes | Seu feedback é muito importante para todos!