Where to put the TDataSource component?

delphi

Solution

I would put the `Datasources` in the Form, since it is only a component to use with visual controls.

Also, you can create `Datasouces` on demand in the form when needed and bind then at runtime to the datasets. In that case it is easy to handle connections between the TDataModule and TForm.

But that's is just MY opinion: I would never use `DBControls` nor `DataSouces`. I prefer to bind my data by hand and have more flexibility than using `DBControls` and `DataSouces` and be stick to some weird mechanics Borland created. But that is just MHO.

Problem

When I split code into TDataModule (=access data) and TFom (=display data), where should I put the TDataSource component? Does it belong to the TDataModule or TForm? And how to handle connenctions between the TDataModule and TForm, when multiple instances are created?

Original source