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

Maximiliano Duarte maximiliano.duarte at gmail.com
Fri Jan 6 01:20:09 CET 2012


When you open the query you object is deleted.
If yuo need only a field name is 

Query1.sql.text:= "select * from mytable";
Query1.open;
Name:=Query1.Fields[0].fieldname;



Enviado desde mi BlackBerry

-----Original Message-----
From: Koenraad Lelong <lazarus1 at de-brouwerij.be>
Date: Thu, 05 Jan 2012 17:20:04 
To: <lazarus at lists.lazarus.freepascal.org>
Reply-To: Lazarus mailing list <lazarus at lists.lazarus.freepascal.org>
Subject: [Lazarus] How to get field-names of a table ?

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.

--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


More information about the Lazarus mailing list