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 <[email protected]>
Date: Thu, 05 Jan 2012 17:20:04 
To: <[email protected]>
Reply-To: Lazarus mailing list <[email protected]>
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
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to