Top Previous Next

Lists all non-aggregate field components of the dataset.


property Fields: TFields;


Use Fields to access field components. If fields are generated dynamically at runtime, the order of field components in Fields corresponds directly to the order of columns in the table or tables underlying a dataset. If a dataset uses persistent fields, then the order of field components corresponds to the ordering of fields specified in the Fields editor at design time.

When ObjectView is True, the fields are stored hierarchically, meaning any child fields of an object field are referenced by the object field and don't appear sequentially after the object field in the TFields.Fields array. When ObjectView is False, the fields are stored sequentially, or flattened out, meaning any child fields of an object field are stored sequentially in the TFields.Fields array.

Accessing fields with the Fields property is useful for applications that:

      • Iterate over some or all fields in a dataset.
      • Work with underlying tables whose internal data structure is unknown at runtime.

If an application knows the data types of individual fields, then it can read or write individual field values through the Fields property. For example, the following statement assigns a field value to the Text property of an edit box:

property Fields: TFields;
Edit1.Text := CusTPSQLTable.Fields.Fields[6].AsString;

The next statements assign a value from an edit box to a field:

CusTPSQLTable.Fields.Fields[6].AsString := Edit1.Text;

The preferred method for retrieving and assigning field values is to use persistent fields or the FieldByName method.

See also: Example: FieldCount,Fields,FieldName