Ver Mensaje Individual
  #2  
Antiguo 01-09-2007
pcicom pcicom is offline
Miembro
 
Registrado: may 2003
Ubicación: MONTERREY MEXICO
Posts: 253
Reputación: 22
pcicom Va por buen camino
Re:

Cita:
Empezado por enecumene Ver Mensaje
Hola compañeros del foro, ahora estoy empezando a trabajar con StringGrids, he intentando llenar datos a partir de un query, ese es el codigo que he estado tratando de hacer:

Código Delphi [-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then begin
 with QArticulo do begin
  if active then Close; //Agregué aquí
  sql.Clear; // y aquí
  SQL.Add(' SELECT ref, articulo, cantidad FROM articulos ');
  SQL.Add('WHERE ref = '+Edit1.Text+'');
  Open;
  if not IsEmpty then begin
  StringGrid1.Cells[1,1]:=fieldbyname('ref').AsString;
  StringGrid1.Cells[2,1]:=fieldbyname('aticulo').AsString;
  end else begin
    ShowMessage('Articulo no existe');
  end;
 end; 
end;
end;

pues como ven no me funciona me aparece ese error:



Estoy trabajando con ADO, nota es la primera vez que trabajo con stringGrids y no he documentacion suficiente acerca de ello a menos que este buscando mal, espero que me puedan echar una mano con eso.

saludos...


Prueba ESTO:


Código Delphi [-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then begin
 with QArticulo do begin
  if active then Close; //Agregué aquí
  sql.Clear; // y aquí
  SQL.Add(' SELECT ref, articulo, cantidad FROM articulos ');
  SQL.Add('WHERE ref = '+QuotedStr(Edit1.Text) );
  Open;
  if not IsEmpty then begin
  StringGrid1.Cells[1,1]:=fieldbyname('ref').AsString;
  StringGrid1.Cells[2,1]:=fieldbyname('aticulo').AsString;
  end else begin
    ShowMessage('Articulo no existe');
  end;
 end; 
end;
end;
__________________
Poco ha de saber el que no pregunta.. Yo por eso soy un pregunton
Responder Con Cita