EPUB | CHM | PDF

TDataSet.Properties.FieldValues

Top Previous Next

Provides access to the values for all fields in the active record for the dataset.

Syntax:

property FieldValues[const FieldName: String]: Variant; default;

Description:

Use FieldValues to read and write values for fields in a dataset. FieldName is the name of a field to read from or write to.

FieldValues reads from and writes to fields whether FieldName represents simple field names, qualified field names for subfields of an object field. Because of this flexibility, it is often preferable to use the FieldValues property (or the FieldByName method) rather than the Fields, FieldList properties, all of which present a more limited selection of the dataset's fields.

FieldValues accepts and returns a Variant, so it can handle and convert fields of any type. Because FieldValues is the default property for TDataSet, you can omit the property name when referencing this property. For example, the following statements are semantically identical and write the value from an edit box into an integer field:

Customers.FieldValues['CustNo'] := Edit1.Text;
Customers['CustNo'] := Edit1.Text;

The next statement reads a string value from a field into an edit box:

Edit1.Text := Customers['Company'];

Because FieldValues always uses Variants, it may be a somewhat slower method of accessing data, than using a field's native format (i.e., using a field's b property), especially in applications that process large amounts of data.

See also: Example: Append,FieldValues,Post