Using Data Modules
Go Up to Building Applications, Components, and Libraries Index
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. But if you plan on reusing groups of database and system objects, or if you want to isolate the parts of your application that handle database connectivity and business rules, then data modules provide a convenient organizational tool.
Note: Data modules are framework-neutral at the XE2 release; that is, you start with the same basic data module for any platform or framework. TDataModule has a pseudo-property ClassGroup that enables you to specify the framework to be used with the data module.
Following are your choices for ClassGroup including the framework and the RTL elements that can be used with each framework-specific choice:
- System.Classes.TPersistent - Delphi RTL, excluding framework-specific elements
- Vcl.Controls.TControl - VCL framework, including RTL elements that are not framework-specific
- FMX.Types.TControl - FMX framework, including RTL elements that are not framework-specific
For more information, see ClassGroup pseudo-property of TDataModule.
There are several types of data modules, including standard, remote, Web modules, applet modules, and services, depending on which edition of Delphi you have. Each type of data module serves a special purpose.
- Standard data modules are particularly useful for single- and two-tiered database applications, but can be used to organize the nonvisual components in any application. For more information, see Creating and Editing Standard Data Modules.
- Remote data modules form the basis of an application server in a multi-tiered database application. They are not available in all editions. In addition to holding the nonvisual components in the application server, remote data modules expose the interface that clients use to communicate with the application server. For more information about using them, see Adding a Remote Data Module to an Application Server Project.
- Web modules form the basis of Web server applications. In addition to holding the components that create the content of HTTP response messages, they handle the dispatching of HTTP messages from client applications. See Creating Internet Server Applications Index for more information about using Web modules.
- Applet modules form the basis of control panel applets. In addition to holding the nonvisual controls that implement the control panel applet, they define the properties that determine how the applet's icon appears in the control panel and include the events that are called when users execute the applet.
- Services encapsulate individual services in an NT service application. In addition to holding any nonvisual controls used to implement a service, services include the events that are called when the service is started or stopped. For more information about services, see Service Applications.
Topics
- Creating and Editing Standard Data Modules
- Accessing a Data Module from a Form
- Adding a Remote Data Module to an Application Server Project
- Setting the Framework Affinity for a Data Module