Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us

Finds a field by its name.

function FieldByName(const FieldName: string): TField;

Call FieldByName to retrieve field information for a field whith only name given. FieldName is the name of an existing field. FieldByName returns the TField component for the specified field. If the specified field does not exist, FieldByName raises an EDatabaseError exception.

FieldName can be the name of a simple field, the name of a subfield of an object field that has been qualified by the parent field's name, or the name of an aggregated field. Because of this flexibility, it is often preferable to use FieldByName rather than the Fields property or the AggFields property.

An application can directly access specific properties and methods of the field returned by FieldByName. For example, the following statement determines if a specified field is a calculated field or not:

if Customers.FieldByName('FullName').Calculated then

MessageDlg(Format('%s is a calculated field. ', ['FullName']), mtInformation, [mbOK], 0);

FieldByName is especially useful at design time for developers who are creating database applications, but when there is no access to the underlying table and therefore persistent field components could not be used.

To retrieve or set the value for a specific field, call the default dataset method FieldValues instead of FieldByName.
        © 2003 - 2020 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 29, 2020