Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Using TFields and the Fields Editor

Читайте также:
  1. A clutch centre holding tool can easily be made using two strips of steel bent over at the ends and bolted together in the middle
  2. A few common expressions are enough for most telephone conversations. Practice these telephone expressions by completing the following dialogues using the words listed below.
  3. A. Rewrite the sentences without using the underlined words. Keep the meaning the same.
  4. Act as Sally. Answer the questions using the conversational formulas trained.
  5. Agree or disagree with the statements using the following
  6. Answer the questions using the information from the text.
  7. B Turn the engine clockwise using a 14 mm socket on the alternator bolt

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 | Нарушение авторских прав


Читайте в этой же книге: Lecture 9. Using Data Controls | Searching a table | KRS 0000234069, Regon 300055546, NIP 6080024482 |
<== предыдущая страница | следующая страница ==>
Using TDataSource events| Defining a calculated field

mybiblioteka.su - 2015-2024 год. (0.007 сек.)