Board index » delphi » Dis[playing values in DBgrid using SQL ....

Dis[playing values in DBgrid using SQL ....

I have a Tquery setup to read an SQL statement from a memobox, but it
will only display actual field names that have been defined in the
paradox table; it does not display calculated fields.

I wanting to display data (including calculated fields) selected and
sorted by SQL in a DBGrid.

Any help much appreciated.
Dave,

 

Re:Dis[playing values in DBgrid using SQL ....


Quote
>I have a Tquery setup to read an SQL statement from a memobox, but it
>will only display actual field names that have been defined in the
>paradox table; it does not display calculated fields.

>I wanting to display data (including calculated fields) selected and
>sorted by SQL in a DBGrid.

Hi Dave,

I'm not quite sure I understand what you are asking.  If you could rephrase
your question I will try to help if I can.

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Re:Dis[playing values in DBgrid using SQL ....


Quote
>Hi Dave,

>I'm not quite sure I understand what you are asking.  If you could rephrase
>your question I will try to help if I can.

>********************************
>Michael Glatz
>glatzfa...@aol.com
>mgl...@briefcase.com

Hi,

Thanks for the offer of assistance, I have expanded the problem below:

I have several calculated fields created by double clicking the table
component and defining the fields. One field shown below:

procedure TForm1.Table1CalcFields(DataSet: TDataset);

begin
if table1EPPOPSPOINTS.value <= 1 then table1EPPOPSCAT.value :='D';
if table1EPPOPSPOINTS.value >=  2 then table1EPPOPSCAT.value :='C';
if table1EPPOPSPOINTS.value >=  4 then table1EPPOPSCAT.value :='B';
if table1EPPOPSPOINTS.value >=  6 then table1EPPOPSCAT.value :='A';

--- snip ----

I have a query component linked to datasource2 which displays several
fields from the table, but it will not display calculated fields in
the DBgrid that displays the information.  If I connect the DBGrid to
the datasource1 that is connected to table1, it displays all the
fields (including the calculated ones). I am needing to restrict the
fields displayed in the grid and also restrict data that is displayed
in the grid
e.g.  if table1EPPOPSPOINTS.VALUE >= 6 THEN show certain fields.

The SQL I have looks like this:

with query1 do
begin
close;
SQL := memo1.lines;
open;
END;

Text in memo1.lines := SELECT SURNAME,INITIAL,LOCATION, EPPOPSPOINTS
FROM DATAFILE WHERE EPPOPSPOINTS > 6

The program will not display EPPOPSPOINTS, it will only display the
fields
that were setup in the paradox table by me; the calculated fields
created by me above will not display.

Thanks,

Dave,

Re:Dis[playing values in DBgrid using SQL ....


Dave,

You can't access calculated fields with SQL because they don't actually
exist in the underlying table - only in the TTable or TQuery.

The way round this is to calculate the fields in your SQL query and use
ORDER BY to do the sorting.

--
Stephen Brown
sbr...@sprocket.win-uk.net

Quote
Glatzfamly wrote in message

<1998091423262500.TAA20...@ladder03.news.aol.com>...
Quote
>>I have a Tquery setup to read an SQL statement from a memobox, but it
>>will only display actual field names that have been defined in the
>>paradox table; it does not display calculated fields.

>>I wanting to display data (including calculated fields) selected and
>>sorted by SQL in a DBGrid.

>Hi Dave,

>I'm not quite sure I understand what you are asking.  If you could rephrase
>your question I will try to help if I can.

Other Threads