Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Destroying reportbuolder fields

edited December 2004 in General
Hello,

I was testing version 7.091 i noticed the following thing:
I have a datamodule containg a reportbuilder component.

In this datamodule i have my own method "CloseDatamodule" which is called
before the datamodule is destroyed:

if Assigned(FDataModuleInstance) then
begin
FDataModuleInstance.CloseDataModule;
FreeAndNil(FDataModuleInstance);
end;


The method "CloseDatamodule" has this code:

// Disconnect all ado data components
for i := 0 to ComponentCount - 1 do
begin
if ( (Components[i] is TCustomAdoDataSet)
and (Components[i] as TCustomAdoDataSet).Active
) then
begin
if ((Components[i] as TCustomAdoDataSet).State in [dsInsert,
dsEdit]) then
begin
(Components[i] as TCustomAdoDataSet).Cancel;
end;

(Components[i] as TCustomAdoDataSet).Close;
end;
end;


When the code starts the ComponentCount is 157.
Then i get an index of bound on nr 75.
Debugging whats happingen i noticed that the Reprtbuilder objects where
beining destroyed during the
for i := 0 to ComponentCount - 1 do
loop. So when the loop started they where there, when the loop is at point
75 they are all gone!!!

Setting the propertty "AutoCreateFields" to false, helped to overcome the
error.
Wat is behaviour already in the eraly packages ( <= 7.04?????)

Eric

Comments

  • edited December 2004

    There is not enough information here for me to determine what is happening.

    If I were debugging this problem, I would add RBuilder\Source and
    Delphi\Lib\Debug to the Delphi environment library path. Then place a stop
    in the TComponent.Destroy method (Classes.pas) and the
    TppCommunicator.Destroy method (RBuilder\Source\ppComm.pas).

    If you would like to create a simple, minimal Delphi project and email in
    zip format to support@digital-metaphors.com we can check it out here. Please
    use only standard Delphi components and RB.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.