RAD Studio |  |

Using data modules
Collapse All
Topics

Name | Description
Accessing a Data Module from a Form | To associate visual controls on a form with a data module, you must first add the data module to the form's uses clause. You can do this in several ways: In the Code editor, open the form's unit file and add the name of the data module to the uses clause in the interface section. Click the form's unit file, choose FileUse Unit, and enter the name of the module or pick it from the list box in the Use Unit dialog. For database components, in the data module click a dataset or query component to open the... more
Adding a Remote Data Module to an Application Server Project | Some editions of Delphi allow you to add remote data modules to application server projects. A remote data module has an interface that clients in a multi-tiered application can access across networks.
Creating and Editing Standard Data Modules | To create a standard data module for a project, choose FileNewOtherDelphi ProjectsDelphi FilesData Module. The IDE opens a data module container on the desktop, displays the unit file for the new module in the Code editor, and adds the module to the current project. At design time, a data module looks like a standard form with a white background and no alignment grid. As with forms, you can place nonvisual components from the Tool palette onto a module, and edit their properties in the Object Inspector. You can resize a data module to... more
Creating Business Rules in a Data Module | Besides writing event handlers for the components in a data module, you can code methods directly in the unit file for a data module. These methods can be applied to the forms that use the data module as business rules. For example, you might write a procedure to perform month-, quarter-, or year-end bookkeeping. You might call the procedure from an event handler for a component in the data module. The prototypes for the procedures and functions you write for a data module should appear in the module's type declaration:
Using Data Modules | 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. 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... more
Naming a Data Module and Its Unit File | The title bar of a data module displays the module's name. The default name for a data module is "DataModuleN" where N is a number representing the lowest unused unit number in a project. For example, if you start a new project, and add a module to it before doing any other application building, the name of the module defaults to "DataModule2." The corresponding unit file for DataModule2 defaults to "Unit2." You should rename your data modules and their corresponding unit files at design time to make them more descriptive. You should especially rename data modules you add... more
Placing and Naming Components | You place nonvisual components in a data module just as you place visual components on a form. Click the desired component on the appropriate category of the Tool palette, then click in the data module to place the component. You cannot place visual controls, such as grids, on a data module. If you attempt it, you receive an error message. For ease of use, components are displayed with their names in a data module. When you first place a component, the module assigns it a generic name that identifies what kind of component it is, followed by a 1.... more
Using Component Properties and Events in a Data Module | Placing components in a data module centralizes their behavior for your entire application. For example, you can use the properties of dataset components, such as TClientDataSet, to control the data available to the data source components that use those datasets. Setting the ReadOnly property to True for a dataset prevents users from editing the data they see in a data-aware visual control on a form. You can also invoke the Fields editor for a dataset, by double-clicking on ClientDataSet1, to restrict the fields within a table or query that are available to a data source and therefore to... more

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!