I have a data module with a ton of TDataset descendent components (ApolloDataSet). I need to set the Database Property for each of them and then Open them. While I could write a long list of code setting and opening each one individually, I'd like to do this by iterating through all the datasets in the data module. This way, I could use the same technique to do other functions such as pack and reindex.
Here's what I have so far - this is a procedure in my data module:
for f := 0 to ComponentCount - 1 do
if Components[f].InheritsFrom(TApolloDataSet) then begin
//If component is a Dataset component
Components[f].DatabaseName := ApDSetLParamDB_PATH.Text;
end; //if dataset
What I get here is a compile error: Undeclared identifier: 'DatabaseName'
Undeclared identifier: 'Open'
If the above lines read (for example):
ApDSetCity.DatabaseName := ApDSetLParamDB_PATH.Text;
then all is fine.
What I need is to be able to access the properties and methods when the component has the form: Components[f]
I'm hoping the answer is an easy one like: Use TDM(Components[f]).DatabaseName
(This doesn't work either)
Anyway - it should be a handy technique once it is resolved.
If there is a better way to handle component properties and methods for all the components on a form, I am all ears.
Thanks for your help