Jump to content

Datasource on the form or on a datamodule


mierlp

Recommended Posts

Hi

 

My application contains about 120 forms and 14 datamodules.

A datamodules is grouped based on functionality. There's a datamodules dmTypes which contains querys regarding a 'type'

lets say : typeEntrance, typeParking, typeMeal, typeCatering, typeArtist, typeBooking,  etc.
 

Sometimes i need a other tables for a lookup functionality and so on this datamodule a put query from a
other table...lets say statusArtist, The datamodules are only containing querys which i need for that specific

functionality/forms

 

The datasource i put on the forms and is add the datamodules which i need in the uses class.

Forms are only containing datasources which are needed for that specific functionality/forms

 

 

WHATS THE BEST PLACE TO PUT THE DATASOURCES...ON A DATAMODULE OF FORM
AND WHAT'S THE REASON BEHIND IT..

 

Link to comment
Share on other sites

Hi,

 

This is considered to be a matter of style. But better to place DataSource components onto the individual forms I think. You can convert a form from using one data module to another by simply changing the DataSet property of the DataSource.

Link to comment
Share on other sites

In a small project-you can use both DataModule and components on the form (frame).
And in a large project, each form contains its own Dataset. The additional advantage is becoming less dependent form (Datamodule).

 

I quickly wrote a small program that considers the components of data access in the project.
And here's what happened:

 

Units (*.pas) - 273
TFDStoredProc - 253
TFDQuery - 29
TFDMemTable - 104

 

If all these components are placed in the datamodule, I will be lost... :)

 

UPD. Of course, you can create a datamodule for each form, then 200 data modules are needed for 200 forms

Link to comment
Share on other sites

I have a project with about 100 forms and no datamodule.

 

The MainModule has about 100 queries and a single db connection,

and no datasources.

 

Each form has from 0 to around 30 queries max, with datasources.

 

Having the datasources on the forms makes things simpler,

as the db-aware components' reference to the DS is local,

and same with the DS-dataset reference.

 

However, since the dataset references to the connection is

not local to the form, I have to open the MainModule with the

connection first, so it is available to the datasets on the forms

before I open them. Also have to make sure the connection

is not live at compile time, otherwise it fails at runtime.

 

To make sure this does not get messed up, I assign all dataset

connection properties in code, at the OnCreate of the forms.

Link to comment
Share on other sites

In a small project-you can use both DataModule and components on the form (frame).

And in a large project, each form contains its own Dataset. The additional advantage is becoming less dependent form (Datamodule).

 

I quickly wrote a small program that considers the components of data access in the project.

And here's what happened:

 

Units (*.pas) - 273

TFDStoredProc - 253

TFDQuery - 29

TFDMemTable - 104

 

If all these components are placed in the datamodule, I will be lost... :)

 

UPD. Of course, you can create a datamodule for each form, then 200 data modules are needed for 200 forms

Hi,

 

When you said Datamodule, are you talking about DataSource?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...