Ver Mensaje Individual
  #1  
Antiguo 14-09-2007
Avatar de enecumene
[enecumene] enecumene is offline
Miembro de Oro
 
Registrado: may 2006
Ubicación: Santo Domingo, Rep. Dom.
Posts: 3.040
Reputación: 22
enecumene Va por buen camino
Problema con STringGrid

Holas de Nuevo compañeros del foro, como dice el titulo tengo un problema con stringgrid, pues es la primera vez que trabajo con ello, codigo:

Código Delphi [-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then begin
if Edit1.Text = '' then begin
     ShowMessage('Item no existe');
     end else begin
ZQuery1.Close;
ZQuery1.SQL.Add('Select item, codigo from items');
ZQuery1.SQL.Add(' where codigo = :cod');
ZQuery1.ParamByName('cod').Value:=Edit1.Text;
ZQuery1.Open;
 if not ZQuery1.IsEmpty then begin
  StringGrid1.Row := StringGrid1.Rowcount - 1;
  StringGrid1.Cells[0,StringGrid1.Row] := ZQuery1.Fields[0].Value;
  StringGrid1.Cells[1,StringGrid1.Row] := ZQuery1.Fields[1].Value;
  StringGrid1.RowCount := StringGrid1.RowCount + 1;
  Edit1.Clear;
  Edit1.SetFocus;
  end else
      ShowMessage('Item no existe');
    end;
  end;
 end;

cuando inserto datos al stringgrid lo hace bien y me crea una nueva linea, pero cuando trato de insertar otro datos mas me tira el siguiente error:

Cita:
---------------------------
Debugger Exception Notification
---------------------------
Project Prueba.exe raised exception class EZSQLException with message 'SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Select item, codigo from items where codigo = '2020'' at line 1'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
que estoy haciendo mal?

adjunto el codigo completo: prueba.zip
__________________

Mi BLOG - ¡Joder, leanse la guia de estilo!
Las Palabras son enanas, los ejemplos gigantes.
Responder Con Cita