[DUG] Creating fields at runtime

Rohit Gupta rohit at cfl.co.nz
Wed Jun 1 10:24:05 NZST 2005


TTWII - Thats the way it is.  :-)

Date sent:      	Wed, 01 Jun 2005 09:35:00 +1200
From:           	Alister Christie <alister at salespartner.co.nz>
To:             	Todd Martin <toddm at kol.co.nz>,
  	NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
Subject:        	Re: [DUG] Creating fields at runtime
Copies to:      	
Send reply to:  	NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
	<mailto:delphi-request at ns3.123.co.nz?subject=unsubscribe>
	<mailto:delphi-request at ns3.123.co.nz?subject=subscribe>

[ Double-click this line for list subscription options ] 

No it's created at runtime:

   q := TQuery.Create(Nil);
     q.DatabaseName := 'Rezy';
     q.SQL.Add('Select Surname, Tit_Init, Greeting, StNo, Street, Add2, 
Add3, Ph1, Ph1Type, Ph2, Ph2Type, Ph3, Ph3Type, Fax, Price, Bedrooms, 
email');
     q.SQL.Add('from contact where status = ''A''');
     q.Name := 'Contact';
//    q.OnCalcFields := qContactCalcField;
//    strfield := TStringField.Create(q);
//    strfield.FieldName := 'RequirementsDesc';
//    strfield.FieldKind := fkCalculated;
//    strfield.DataSet := q;
     q.Open;

The commented out bit creates the calculated field which obscures the 
other fields once created.  I want to be able to add all the other 
fields to the q.Fields property, but not have to write the code to add 
each field individually.

Any Suggestions?

Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington

Todd Martin wrote:
> Are your existing fields in the dataset create at design time?
> 
> ----- Original Message ----- From: "Alister Christie" 
> <alister at salespartner.co.nz>
> To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
> Sent: Tuesday, May 31, 2005 1:29 PM
> Subject: [DUG] Creating fields at runtime
> 
> 
>> I'm creating a TQuery (descriptively called q) at runtime with a with 
>> a query such as "select * from contact".  However I want to add a 
>> calculated field to this using the following code
>>     strfield := TStringField.Create(q);
>>     strfield.FieldName := 'RequirementsDesc';
>>     strfield.FieldKind := fkCalculated;
>>     strfield.DataSet := q;
>> However, by adding a calculated field I hide all the fields in the 
>> fielddefs.  Does anyone know of a way around this, either by putting 
>> the calculated field in q.fielddefs or adding all the fields to 
>> q.fields in some easy fashion
>>
>>
>> -- 
>> Alister Christie
>> Computers for People
>> Ph: 04 471 1849 Fax: 04 471 1266
>> http://www.salespartner.co.nz
>> PO Box 13085
>> Johnsonville
>> Wellington
>> _______________________________________________
>> Delphi mailing list
>> Delphi at ns3.123.co.nz
>> http://ns3.123.co.nz/mailman/listinfo/delphi
>>
>>
> 
> 
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
Regards

Rohit

======================================================================
CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
PH    (649) 489-2280 
FX    (649) 489-2290
email rohit at cfl.co.nz  or  r.gupta at xtra.co.nz
======================================================================




More information about the Delphi mailing list