Board index » delphi » Best Practice: Sharing Data Components

Best Practice: Sharing Data Components

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?

I try to code as efficiently as I can saw this as
a possible means of doing so.

TIA,  Otto Porter

 

Re:Best Practice: Sharing Data Components


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

Yes that works fine as long as you want the components pointing to the same
record.

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

Then you don't need to worry about them sharing the same record but if you leave
the tables open in the datamodel then the next form you open will open to the
current record in the datamodel table.

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?

It is stable and there are no problems with multiple forms sharing a tdataset
component.  You won't see much code saving

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads