Читайте также:
|
|
TField components correspond to database columns. They are created
• At run time by Delphi whenever a dataset component is active. This creates a dynamic set of TFields that mirrors the columns in the table at that time.
• At design time through the Fields Editor. This creates a persistent set of TFields that does not change, even if the structure of the underlying table changes.
There are TField components corresponding to all possible data types, including
TStringField, TSmallintField, TIntegerField, TWordField, TBooleanField, TFloatField, TCurrencyField, TBCDField, TDateField, TTimeField, and TDateTimeField. This chapterdiscusses TFields in general, and the discussion applies to all the different sub-types. For information on the properties of a specific type, see the online VCL Reference.
2. What are TField components?
All Delphi data-aware components rely on an underlying object class, TField. Although not visible on forms, TField components are important because they provide an application a direct link to a database column. TFields contain properties specifying a column’s data type, current value, display format, edit format, and other characteristics. TField components also provide events, such as OnValidate, that can be used toimplement field-based validation rules.
Each column retrieved from a table has a corresponding TField component. By default, TField components are dynamically generated at design time when the Active propertyof a TTable or TQuery component is set to True. At run time, these components are also dynamically generated. Dynamic generation means Delphi builds TField components based on the underlying physical structure of a database table each time the connection to the table is activated. Thus, dynamically generated TFields always correspond to the columns in the underlying database tables.
To generate a persistent list of TField components for an application, use the Fields Editor. Using the Fields Editor to specify a persistent list of TField components is smart programming. Creating TField components with the Fields Editor provides efficient, readable, and type-safe programmatic access to underlying data. It guarantees that each time your application runs, it uses and displays the same columns, in the same order, every time, even if the physical structure of the underlying database has changed. Creating TField components at design time guarantees that data-aware components and program code that rely on specific fields always work as expected. If a column on which a persistent TField component is based is deleted or changed, then Delphi generates an exception rather than running the application against a non-existent column or mismatched data.
Дата добавления: 2015-10-23; просмотров: 116 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Using TDataSource events | | | Defining a calculated field |