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

How can I free this OBJECT?

edited June 2003 in End User
This procedure create a dataView and at first time I run it and works fine
but if I run it next time it gives me an error
"A Componant named daBDEQueryDataView1 already exists in at <>
owned by TAppplication."
I couldn't able to find this component and making it nil any help on this
one?

-Bhoj


procedure TfrmQueryWizard.CreateDataViews;
var
FDataSettings: TppDataSettings;
Temp : TComponent;
begin
DeleteDataModule;
FreeObject(lDataView); //Make sure it must be free else you will get an
error message
FreeObject(lDataModule);
lDataModule := daGetDataModule( fReport);
if lDataModule = nil then begin
lDataModule := TdaDataModule.CreateForReport(fReport);
end;
lDataModule.FreeNotification( self);
lDataView := TdaBDEQueryDataView.Create(lDataModule);
lDataView.FreeNotification( self);
lDataView.Parent := lDataModule; //I can go up to here and got an error
when it try to assign a Parent ???
lDataView.Init;
end;

Comments

  • edited June 2003
    Give it a unique name before assiging the parent property. Then it will
    work.The data module is owned by the form, and the dataviews are owned by
    the form, so they will be freed when the form is freed, unless you free them
    manually. You have to give the dataviews unique names in order to add the
    next dataview.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Hi Jim,
    how do I give it a uniqueName? Do you have any code sample to use your
    GetUniqueName function?
    Can you make my example current by using your GetUniqueName?

    Thank you
    -Bhoj



  • edited June 2003
    You can just call ppGetUniqueName in ppUtils.pas. Pass the form, any string
    prefix you want, ie. 'my' and finally pass the component reference.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.