Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the DataModule (dm) in Delphi?

Tags:

What is the purpose of having a DataModule in your project? Does it have any special properties compared to a normal class or module? What are the conventions of what it's usually used for?

like image 871
Jessica Brown Avatar asked Sep 27 '12 16:09

Jessica Brown


People also ask

What is a DataModule?

Data modules are source objects that contain data from data servers, uploaded files, or other data modules, and are saved in My content or Team content. Data servers. Data servers are databases for which connections exist.

How to add DataModule in Delphi?

To add the data module to your project, right-click the project name in the Project Manager and then click Add New > Other... to display the New Items dialog. Select Data Module and click OK.

What is a data module c++ builder?

A data module is like a special form that contains nonvisual components. All the components in a data module could be placed on ordinary forms alongside visual controls.


2 Answers

A datamodule is a non-visual "form" (container) that can contain non-visual components (usually database components, though any component can be added, such as dialogs and Indy components) that can then be shared by many forms.

This wiki explains further: Delphi Wikki.

like image 105
SteB Avatar answered Sep 19 '22 09:09

SteB


It is normally used for Dataset and DataSource objects to keep them in a central location. A DataModule can only contain nonvisual components on it but are not just limited to Data Access components. You could put a TTimer on it and SaveDialog etc...

It can be useful when you have multiple forms, needing to change the code only in one place, instead of every form.

like image 40
Shambhala Avatar answered Sep 21 '22 09:09

Shambhala