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 datum, but in the database there are data. Does anyone know how I can fix this?
Additional information: the SQL code is correct because I tried to generate it by Delphi and then run in Firebird and returned the data correctly.
the biggest problem of the above code is that the command
open
is what you want, it executes the SQL command and returns the data to the Dataset. oexecSql
is for SQL data changes, which do not return tuples for Dataset. Even in the answer Execsql is unnecessary, and using parameters was a good solution– Caputo