Non-instaniated fields

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
CAC
Newbie
Newbie
Posts: 44
Joined: Tue Jun 20, 2006 12:00 am
Location: Plain City, Ohio
Contact:

Non-instaniated fields

Post by CAC » Tue Apr 17, 2007 12:40 am

I am having great success getting TeeChart to cooperate, but now have problem I need some help with. I have a dynamic query that can result in a variety of columns using my Delphi 7 app. I don't instantiate the fields in the datamodule, to allow it to accept a variety of columns. If I instantiate the columns I need for the graph, then I leave behind columns that my user may want. If I instantiate all of them, then I lose my advantage of speedy custom searches.

I tried instantiating the ones I needed long enough to get it running, but If I delete them from the query object afterwards the program won't compile.

Any ideas?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 17, 2007 10:22 am

Hi CAC,

Have you also deleted all references to removed ones? Which compilation error do you get?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

CAC
Newbie
Newbie
Posts: 44
Joined: Tue Jun 20, 2006 12:00 am
Location: Plain City, Ohio
Contact:

Post by CAC » Tue Apr 17, 2007 10:49 am

This is the piece of code that gives me a problem:
with dm.qryLResults do
begin
DisableControls;
try
First;
while not(EOF) do
Begin
if dm.qryLResultsSAMPLE_NAME.AsString = SampleName then
if dm.qryLResultsANALYTE.AsString = AnalyteName then
begin
SampleSeries.AddXY(dm.qryLResultsSAMPLE_DATE.AsDateTime, dm.qryLResultsRESULT.AsFloat);
end;

Next;
end;
finally
EnableControls;
end;
if I don't have the fields instantiated, then I get an error like this:
[Error] AnalyticalGraph.pas(192): Undeclared identifier: 'qryLResultsSAMPLE_NAME'
thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 17, 2007 1:17 pm

Hi CAC,

Before the if statement you could try checking the number of fields in dm or loop through them to check if fields with given names exists.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

CAC
Newbie
Newbie
Posts: 44
Joined: Tue Jun 20, 2006 12:00 am
Location: Plain City, Ohio
Contact:

Post by CAC » Wed Apr 18, 2007 12:51 pm

I know these columns of data will exist at run time, because the dynamic query in my code is set to run a specific list of key columns. The "catch" is assigning these columns to TeeChart at design time so I can compile the program. It appears that if I instantiate one column, I have to instantiate them all, which defeats the purpose.

One option I have thought of is running two queries, my dynamic query (which will fill grids, and reports), and a second one with the columns needed for the graph already instaniated in a TIBOQuery object.

CAC
Newbie
Newbie
Posts: 44
Joined: Tue Jun 20, 2006 12:00 am
Location: Plain City, Ohio
Contact:

Post by CAC » Fri Apr 20, 2007 1:40 am

I got some advice from a friend of mine...

When I replaced all the references like

"dm.qryLResultSample_NAME.AsString"

with

"FindField('SAMPLE_NAME').asString"

it worked great!

Post Reply