[Lazarus] How to get field-names of a table ?

Koenraad Lelong lazarus1 at de-brouwerij.be
Thu Jan 5 17:20:04 CET 2012


Hi,

I have a tsqlQuery with as sql : "select * from mytable". I don't add 
the fields at design-time by double-clicking on the query and then 
adding the fields. I would like to do this at run-time.
I looked at the properties of the sqlQuery and tried some of the 
methods, but I can't find anything that works.
I tried in the create of the datamodule :

tmpField:=TStringField.Create(nil);
tmpField.FieldKind:=fkData;
tmpField.FieldName:='COUNT';
MyQuery.Fields.Add(tmpField);
MyQuery.Open;

Destroy of the datamodule :

MyQuery.Close;
tmpField.Free;

This compiles fine and runs fine until I try to use the COUNT-field, 
which does exist in the table.
Closing the application without using the field also creates a segfault.

Any hints how to do what I want ?
Database = firebird, lazarus = 0.9.30

Thanks,

Koenraad Lelong.




More information about the Lazarus mailing list