Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   ADOQUERY no trabaja.... (https://www.clubdelphi.com/foros/showthread.php?t=59521)

ilichhernandez 29-08-2008 20:43:41

ADOQUERY no trabaja....
 
Estimado(a)s, he comenzado a trabajar en un proyecto y ocupo componentes ADO, buscando aqui en el foro he encontrado algunas cosillas pero no he podido establecer por que esta query no me funciona. Agradeceria enormemente si alguien me orientara y/o me comentara sobre esta adoquery, gracias desde ya....


Código Delphi [-]
begin 
dm.qlab.SQL.Clear; 
dm.qlab.sql.text := 'Select * from stock'; 
if combobox1.Text = 'PRODUCTO' then 
Begin    
dm.qlab.SQL.text := 'Select * from stock  where producto = ' + QuotedStr(Edit1.text); 
end; 
if combobox1.Text = 'MZ' then 
Begin    
dm.qlab.SQL.text := 'Select * from stock  where subpro = ' + QuotedStr(Edit1.text); 
end; 
if combobox1.text <> 'Seleccione' then    
Begin       
dm.qlab.Open;    
End    
else    
Begin      
Showmessage('Debe seleccionar un criterio de busqueda antes de presionar el boton');    
end; 
end;

enecumene 29-08-2008 20:55:50

Hola, prueba de la siguiente manera:

Código Delphi [-]
begin 
dm.qlab.SQL.Clear; 
dm.qlab.sql.text := 'Select * from stock'; 
if combobox1.Text = 'PRODUCTO' then 
Begin    
dm.qlab.SQL.Add(' where producto = '+ QuotedStr(Edit1.text)+' '); 
end; 
if combobox1.Text = 'MZ' then 
Begin    
dm.qlab.SQL.Add(' where subpro = ' + QuotedStr(Edit1.text) +' '); 
end; 
if combobox1.text <> 'Seleccione' then    
Begin       
dm.qlab.Open;    
End    
else    
Begin      
Showmessage('Debe seleccionar un criterio de busqueda antes de presionar el boton');    
end; 
end;

Saludos.

Caral 29-08-2008 20:57:44

Hola

Código Delphi [-]
begin 
dm.qlab.SQL.Clear; 
      if combobox1.text <> 'Seleccione' then    
      Begin       
      dm.qlab.sql.text := 'Select * from stock';
      dm.qlab.Open;
      end    
     else    
     Begin      
     Showmessage('Debe seleccionar un criterio de busqueda antes de presionar el boton');    
     end; 
     if combobox1.Text = 'PRODUCTO' then 
     Begin 
     dm.qlab.Close;
     dm.qlab.SQL.text := 'Select * from stock  where producto = ' + QuotedStr(Edit1.text); 
     dm.qlab.Open;
end; 
     if combobox1.Text = 'MZ' then 
     Begin
     dm.qlab.Close; 
     dm.qlab.SQL.text := 'Select * from stock  where subpro = ' + QuotedStr(Edit1.text); 
    dm.qlab.Open;end; 
end;
Saludos

ilichhernandez 29-08-2008 21:09:17

Extrañamente, he probado las dos opcione sque me han comentado, pues..... las dos opciones no arrojan ningun error pero no me muestran lo que intento mostrar..... que extraño ?no¿.....muchas gracias de todas formas...

Caral 29-08-2008 21:11:41

Hola
Y que muestra?, no muestra nada?.
Saludos

enecumene 29-08-2008 21:13:46

Me faltó poner lo siguiente :D:

Código Delphi [-]
begin 
dm.qlab.SQL.Clear; 
dm.qlab.sql.text := 'Select * from stock'; 
if combobox1.Text = 'PRODUCTO' then 
Begin    
dm.qlab.SQL.Add(' where producto = '+ QuotedStr(Edit1.text)+' '); 
dm.qlab.open;
end; 
if combobox1.Text = 'MZ' then 
Begin    
dm.qlab.SQL.Add(' where subpro = ' + QuotedStr(Edit1.text) +' '); 
dm.qlab.open;
end; 
if combobox1.text <> 'Seleccione' then    
Begin       
dm.qlab.Open;    
End    
else    
Begin      
Showmessage('Debe seleccionar un criterio de busqueda antes de presionar el boton');    
end; 
end;

ilichhernandez 29-08-2008 21:14:16

Que leso que he sido...... lo que sucedia es que habia asociado mal un datasource, por eso no veia los cambios en el grid..... a veces hace mal el copy/paste..... probé en definitiva la version de Caral y me ha funcionado de maravillas, muchisimas gracias por la ayuda.....Saludos, y por supuesto agradecimientos a ambos por su tiempo.........y conocimiento....

Caral 29-08-2008 21:16:40

Hola
Ufffffff, por un momento pensé que ya me había olvidado.:D
PD: La opción de Enecumene (La segunda) debería funcionar también.:p:D
Saludos


La franja horaria es GMT +2. Ahora son las 20:49:07.

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