Board index » delphi » creating TadoDatsets variables dynamically
Keith G Hicks
![]() Delphi Developer |
creating TadoDatsets variables dynamically2005-06-09 01:18:56 PM delphi72 I need to create one or more data sets dynamically in code. The number created is dependent upon some parameters in a table. I need to name them like "dstRpt1", "dstRpt2", etc. and be able to refer to them when setting up parameters and such. Something like this: for x := 1 to 3 do begin 'dstRpt' + Trim(IntToStr(x)) := TAdoDataset.Create(nil); TAdoDataSet('dstRpt' + Trim(IntToStr(x))).CommandType := cmdStoredProc; TAdoDataSet('dstRpt' + Trim(IntToStr(x))).Connection := MyConn; TAdoDataSet('dstRpt' + Trim(IntToStr(x))).CommandText := 'sp1;1'; TAdoDataSet("dstRpt" + Trim(IntToStr(x))).Parameters.Refresh; ... // more parameter settings, then prepared and active, etc. ... // add the dataset to the report (FR3) end; ... // run the report ... // free the datasets Obviously the above will not work. I don't know how to create it without knowing the name during design time and dont' know how to refer to the dataset once it is been created. I presume from my reading that I need to use NEW and pointers but the example in the help file is limited and I don't understand how to go about this. Thanks, Keith |