Accessing Field Values with a Dataset's Fields Property
You can access the value of a field with the Fields property of the dataset component to which the field belongs. Fields maintains an indexed list of all the fields in the dataset. Accessing field values with the Fields property is useful when you need to iterate over a number of columns, or if your application works with tables that are not available to you at design time.
To use the Fields property you must know the order of and data types of fields in the dataset. You use an ordinal number to specify the field to access. The first field in a dataset is numbered 0. Field values must be converted as appropriate using each field component's conversion properties.
For example, the following statement assigns the current value of the seventh column (Country) in the Customers table to an edit control:
Edit1.Text := CustTable.Fields.AsString;
Edit1->Text = CustTable->Fields->Fields->AsString;
Conversely, you can assign a value to a field by setting the Fields property of the dataset to the desired field. For example:
Customers.Edit; Customers.Fields.AsString := Edit1.Text; Customers.Post;
Customers->Edit(); Customers->Insert(); Customers->Fields->Fields->AsString = Edit1->Text; Customers->Post();