Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A TList of TQuery's

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have a TList set in one of my forms (namely lcvQueryList) which I use to add TQuery components to as required (using 'lcvQueryList.Add(DataModule1.Query1)').
I am able to use items in this list to set the datasource against DBChart Series (using 'DBChart1.Series.DataSource := lcvQueryList.Items[tpI]).
However I remain unable to use the queries in this list, i.e. cycling through the list and setting each to not active. I am trying to use the syntax :
for tpI := 0 to (lcvQueryList.Count - 1) do
begin
(lcvQueryList.Items[tpI] AS TQuery).Active := False;
end;
When I attempt to compile this code I am getting the error : 'Operator not applicable for this operand type.'.
Can anyone give me a pointer as to how I might cycle through my list of TQuery components and process each in the same way (i.e. setting Active := False, or SQL.Clear).
Thanks in advance.
Steve
 
Thanks for the feedback. After spending a while banging my head against a wall I came across the same syntax and put it to good use.
Thanks.
Steve
 
The reason is that TObject doesn't have runtime type info - to use AS and IS operators your object must descend from TInterfacedObject. Unfortunately, TList holds TObjects, which don't descend from TInterfacedObject. :)

TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top