Board index » delphi » Can Data Access Components be shared?

Can Data Access Components be shared?

Is it OK to share a Data Access component
between two or more Data Control Components?

Say I have a TTable:Table1 and DataSource:Dstable1
which are contained in a DataModule.

Then I have a Form1 which contains a DbGrid connected
to Table1, which will be used to view/edit, etc. the records
in the table.  Form1 is NOT autocreate.

I also have a Form2 which contains a DbGrid also connected
to Table1, which will be used to view/edit, etc. the records
in the table.  Form2 is NOT autocreate.

The forms will never be created or exist simultaneously as
they are shown modally.

Is this type of sharing OK or can it lead to unstable behavior
or other problems?  Does it significantly save resources or
reduce code size?

TIA,  Otto Porter

 

Re:Can Data Access Components be shared?


Otto Porter gravada:

Quote
> Is it OK to share a Data Access component
> between two or more Data Control Components?

Yes, so far you take care clearing all filters and checking for the
correct indexes when changing from a form to other.

Quote
> Is this type of sharing OK or can it lead to unstable behavior
> or other problems?  Does it significantly save resources or
> reduce code size?

Yes, specially with moving default values at new record, validating
fields before post, etc, centering all this care in the DataModule.

Re:Can Data Access Components be shared?


If I might add: remember that when you scroll a shared table all of the
attached controls will get updated. This can have significant performance
and logic implications.

Other Threads