I can not load firebird data in Delphi XE2 using TZQuery

0

I have a TZQuery created, and I try to load the fields SEQ_CTE and SERIE_CTE according to the code below:

ZQuery1.sql.text :=
    'select * from C000004 where filial = '' + frmprincipal.spanel1.caption + ''';
  ZQuery1.open;
  ZQuery1.execsql;

  DBEdit2.text := ZQuery1.fieldbyname('SEQ_CTE').asstring;
  eserie.text := ZQuery1.fieldbyname('SERIE_CTE').asstring;

  showmessage(ZQuery1.fieldbyname('SERIE_CTE').asstring);

  ZQuery1.close;

The answer that the system returns is an empty data, but in the database there is data. Does anyone know how I can do this?

Additional information: The SQL code is correct because I tried to generate it by delphi and then run it on firebird and returned the data correctly.

    
asked by anonymous 17.08.2014 / 22:30

1 answer

2

I was able to solve in a very interesting way, what I saw in this video: link

To solve, I went into the params property of the components and created a call Tfilial

In the SQL property I put the following code: select * from C000004 where filial = :Tfilial

My delphi code quoted above looks like this:

ZQuery1.Params.ParamValues['Tfilial'] := frmprincipal.spanel1.caption;
  ZQuery1.execsql;
  ZQuery1.Active := true;

  DBEdit2.text := ZQuery1.fieldbyname('SEQ_CTE').asstring;
  eserie.text := ZQuery1.fieldbyname('SERIE_CTE').asstring;

  showmessage(ZQuery1.fieldbyname('SERIE_CTE').asstring);
    
17.08.2014 / 23:31