Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Determina si existe un registro (https://www.clubdelphi.com/foros/showthread.php?t=70517)

agustin173 26-10-2010 00:27:47

Determina si existe un registro
 
hola nuevamente

tengo un problema para saber si existe un registro me explico mejor

Estoy usando delphi 7
una tabla llamada = Area
un edit llamado = EDArea
un combobox llamado = CBPaisBuscar
Adoquery llamado = Temp

Código Delphi [-]
// Determina si Existe un Registro en la Base de Datos
 with Temp do
  begin
    Temp.close;
    Temp.sql.Clear;
    Temp.sql.Add('select Area,Pais from Area');
    Temp.sql.Add('where Area = '+QuotedStr(EDAreaBuscar.Text));
    Temp.open
  end;
   if not Temp.IsEmpty then
     raise exception.Create('Registro Existe');
 end;

Lo que yo deseo es que si el registro del Area y Pais son igual al de la base de dato me diga registro existe.

duilioisola 26-10-2010 00:37:27

Solo debes agregar "and pais = "LoQueDigaElCombo"
El SQL quedaría así:
Código SQL [-]
select Area, Pais from Area
where 
Area=:ParametroArea and
Pais=:ParametroPais
Código Delphi [-]
// Determina si Existe un Registro en la Base de Datos
 with Temp do
  begin
    Temp.close;
    Temp.sql.Clear;
    Temp.sql.Add('select Area,Pais from Area');
    Temp.sql.Add('where Area = '+QuotedStr(EDAreaBuscar.Text));
    Temp.sql.Add('and pais = '+QuotedStr(CBPaisBuscarText));
    Temp.open
  end;
   if not Temp.IsEmpty then
     raise exception.Create('Registro Existe');
 end;

agustin173 26-10-2010 00:50:24

muchas gracias duioisola me sirvio de mucho se resolvio el problema muchas gracias

Te lo agradesco


La franja horaria es GMT +2. Ahora son las 03:42:55.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi