About the TQDBItem component

Purpose
TQDBItem and TQDBView build upon TQDB by defining a field structure for QDB files.

Tasks
TQDBItem is meant primarily as an adjunct to TQDBView but it can be used separately. TQDBItem provides access to a structured QDB file field by field without the overhead of displaying the retrieved data in a panel. It may be easier to understand TQDBItem having first mastered TQDBView.

File Structure
A structured QDB file's structural information is stored as administrative data within the file according to a simple but flexible scheme. Files structured by QDBItem or QDBView thus form a special subset of QDB files: any QDBItem file can be accessed by a TQDB component but only some QDB files are accessible to TQDBItem. All valid QDBItem files are also valid QDBView files.

The primary way to define a file structure is via TQDBView which does the job visually. Changing a file's structure (by adding, removing, or renaming fields) is also best done using TQDBView's component editor. It is possible, though, to use TQDBItem's methods to do the job.

The structural information of a QDB file will usually be loaded automatically by TQDBView but can also be loaded into memory by FetchStructure. ClearStructure erases the structure both in memory and in the file on disk. Finally, a structure in memory can be written to a file by StoreStructure. The in-memory structure can be independently constructed, field-by-field, using AddField.

The file structure is accessed through the FieldCount, FieldNames, and FieldTypes properties. The FieldIndex method looks up a field index by name.

Access to Individual Fields
Before a field can be accessed the item must have been loaded from file and parsed into fields by the Fetch method. This happens behind the scenes so you should rarely need to call Fetch directly. Fetch is called implicitly by the FirstItem, PrevItem, NextItem, LastItem, Refresh, Edit, Insert, and Post methods which are the primary tools you should use to operate on a QDB file via TQDBItem..

Once stationed at the item of your choice the contents of its fields are available via the AsBoolean, AsInteger, AsDateTime, AsReal, and AsString properties. Lower-level access is also possible through the GetField method but is not recommended for general use.