En la primera sentencia que haces, no esta bien por que te traes todos los pacientes y solo te compara uno, de los xx que te trae.
Cita:
Querypac.Close;
querypac.SQL.Clear;
Querypac.Sql.Text := 'Select * From pacientes';
Querypac.Open;
if ((Querypac.FieldValues['nombre']= edit3.Text)) then //edit 3 es donde pongo el nombre del paciente
begin
showmessage('El usuario ya existe');
exit;
end
end;
|
Lo correcto seria:
Código Delphi
[-]Querypac.Close;
querypac.SQL.Clear;
Querypac.Sql.Text := 'Select count(*) AS Existe From pacientes where nombre = ' + QuotedStr(edit3.Text);
Querypac.Open;
if (Querypac.FieldValues['Existe'] > 0) then begin
showmessage('El usuario ya existe');
exit;
end
end;
Un saludo.