Jump to content
emileverh

Do runtime created forms close the TFDQuery connections?

Recommended Posts

Hi team!

 

frmSelectFooter := TfrmSelectFooter.Create(self);

if frmSelectFooter.ShowModal = mrOk then

begin

...

end;

FreeAndNil( frmSelectFooter );

 

If there are TFDQuery's used in that form, do I need to close explicitly close the query? In other words, are (database) resources still in use?

 

Thanks!

Emile

Share this post


Link to post

Depends where the TFDConnection is defined, are you using a shared data module or creating it in the form?  Is it pooled?

Share this post


Link to post
Just now, Tom Chamberlain said:

Depends where the TFDConnection is defined, are you using a shared data module or creating it in the form?  Is it pooled?

The TFDConnection is on a central place in the program on a different datamodule. ( MySQL and the property 'Pooled' is left default, which is False )

Share this post


Link to post

All components that have the form as Owner (which includes all components dropped on the form in the IDE designer) are automatically destroyed when the form is destroyed. So your query components are destroyed but whether that automatically releases serverside resources depends on how the component, especially its destructor, is implemented. But a TFDQuery will close the query when it is destroyed, so your scenario is OK.

  • Like 1

Share this post


Link to post
Just now, PeterBelow said:

All components that have the form as Owner (which includes all components dropped on the form in the IDE designer) are automatically destroyed when the form is destroyed. So your query components are destroyed but whether that automatically releases serverside resources depends on how the component, especially its destructor, is implemented. But a TFDQuery will close the query when it is destroyed, so your scenario is OK.

Thanks for the quick reply!!  😉

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×