Board index » delphi » How to use DisplayFormat on a SQL field

How to use DisplayFormat on a SQL field

How do I assign a DisplayFormat to a field calculated with a SQL statement ?

select sum(amount) as Total
from ....

I want Total to be displayed on a DBGrid with the format '#0,00', but I
don't know how to do since Total is not recognized as a field by Delphi.

Anyone can help ? Thanks in advance

 

Re:How to use DisplayFormat on a SQL field


MyQuery.Fields[0].DisplayFormat := '#0,00'

Alfred.

"Franco" <franco.jo...@tin.it> schreef in bericht
news:3kW69.215457$Jj7.5039232@news1.tin.it...

Quote
> How do I assign a DisplayFormat to a field calculated with a SQL statement
?

> select sum(amount) as Total
> from ....

> I want Total to be displayed on a DBGrid with the format '#0,00', but I
> don't know how to do since Total is not recognized as a field by Delphi.

> Anyone can help ? Thanks in advance

Re:How to use DisplayFormat on a SQL field


I tried, but I get : Undeclared identifier: 'displayformat'.

"Alfred ten Hoeve" <Alfred.NoS...@SimpelProg.nl> ha scritto nel messaggio
news:3d5c5426$0$222$4d4ebb8e@news.nl.uu.net...

Quote
> MyQuery.Fields[0].DisplayFormat := '#0,00'

> Alfred.

> "Franco" <franco.jo...@tin.it> schreef in bericht
> news:3kW69.215457$Jj7.5039232@news1.tin.it...
> > How do I assign a DisplayFormat to a field calculated with a SQL
statement
> ?

> > select sum(amount) as Total
> > from ....

> > I want Total to be displayed on a DBGrid with the format '#0,00', but I
> > don't know how to do since Total is not recognized as a field by Delphi.

> > Anyone can help ? Thanks in advance

Re:How to use DisplayFormat on a SQL field


"Franco" <franco.jo...@tin.it> schrieb im Newsbeitrag
news:7vr79.222864$Jj7.5267559@news1.tin.it...

Quote
> I tried, but I get : Undeclared identifier: 'displayformat'.

(MyQuery.FieldByName('Total') as TNumericField).DisplayFormat := '#0.00';

Andreas Schmidt

Re:How to use DisplayFormat on a SQL field


YES, now it's OK ! Thanks

"Andreas Schmidt" <a_j_schm...@rocketmail.com> ha scritto nel messaggio
news:ajqvek$1dhr67$1@ID-13084.news.dfncis.de...

Quote

> "Franco" <franco.jo...@tin.it> schrieb im Newsbeitrag
> news:7vr79.222864$Jj7.5267559@news1.tin.it...
> > I tried, but I get : Undeclared identifier: 'displayformat'.

> (MyQuery.FieldByName('Total') as TNumericField).DisplayFormat := '#0.00';

> Andreas Schmidt

Other Threads