Understanding Datasets - Overview

From RAD Studio
Jump to: navigation, search

Go Up to Understanding Datasets Index


The fundamental unit for accessing data is the dataset family of objects. Your application uses datasets for all database access. A dataset object represents a set of records from a database organized into a logical table. These records may be the records from a single database table, or they may represent the results of executing a query or stored procedure.

All dataset objects that you use in your database applications descend from Data.DB.TDataSet, and they inherit data fields, properties, events, and methods from this class.

TDataSet is a virtualized dataset, meaning that many of its properties and methods are virtual or abstract. A virtual method is a function or procedure declaration where the implementation of that method can be (and usually is) overridden in descendent objects. An abstract method is a function or procedure declaration without an actual implementation. The declaration is a prototype that describes the method (and its parameters and return type, if any) that must be implemented in all descendent dataset objects, but that might be implemented differently by each of them.

Because TDataSet contains abstract methods, you cannot use it directly in an application without generating a runtime error. Instead, you either create instances of the built-in TDataSet descendants and use them in your application, or you derive your own dataset object from TDataSet or its descendants and write implementations for all its abstract methods.

TDataSet defines much that is common to all dataset objects. For example, TDataSet defines the basic structure of all datasets: an array of Data.DB.TField components that correspond to actual columns in one or more database tables, lookup fields provided by your application, or calculated fields provided by your application. For information about TField components, see "Working with field components."

The following topics describe how to use the common database functionality introduced by TDataSet. Bear in mind, however, that although TDataSet introduces the methods for this functionality, not all TDataSet dependants implement them. In particular, unidirectional datasets implement only a limited subset.

See Also