Go Up to Using ADO datasets
TADODataSet is a general-purpose dataset for working with data from an ADO data store. Unlike the other ADO dataset components, TADODataSet is not a table-type, query-type, or stored procedure-type dataset. Instead, it can function as any of these types:
- Like a table-type dataset, TADODataSet lets you represent all of the rows and columns of a single database table. To use it in this way, set the CommandType property to cmdTable and the CommandText property to the name of the table. TADODataSet supports table-type tasks such as
- Assigning indexes to sort records or form the basis of record-based searches. In addition to the standard index properties and methods, TADODataSet lets you sort using temporary indexes by setting the Sort property. Indexed-based searches performed using the Seek method use the current index.
- Emptying the dataset. The DeleteRecordsDeleteRecords method provides greater control than related methods in other table-type datasets, because it lets you specify what records to delete.
The table-type tasks supported by TADODataSet are available even when you are not using a CommandType of cmdTable.
- Like a query-type dataset, TADODataSet lets you specify a single SQL command that is executed when you open the dataset. To use it in this way, set the CommandType property to cmdText and the CommandText property to the SQL command you want to execute. At design time, you can double-click on the CommandText property in the Object Inspector to use the Command Text editor for help in constructing the SQL command. TADODataSet supports query-type tasks such as
- Using Parameters in Queries.
- Setting up master/detail relationships using parameters.
- Preparing the query in advance to improve performance by setting the Prepared property to True.
- Like a stored procedure-type dataset, TADODataSet lets you specify a stored procedure that is executed when you open the dataset. To use it in this way, set the CommandType property to cmdStoredProc and the CommandText property to the name of the stored procedure. TADODataSet supports stored procedure-type tasks such as
- Working with Stored Procedure Parameters.
- Fetching Multiple Result Sets.
- Preparing the stored procedure in advance to improve performance by setting the Prepared property to True.
In addition, TADODataSet lets you work with data stored in files by setting the CommandType property to cmdFile and the CommandText property to the file name.
Before you set the CommandText and CommandType properties, you should link the TADODataSet to a data store by setting the Connection or ConnectionString property. This process is described in Connecting an ADO Dataset to a Data Store. As an alternative, you can use an RDS DataSpace object to connect the TADODataSet to an ADO-based application server. To use an RDS DataSpace object, set the RDSConnection property to a Data.Win.ADODB.TRDSConnection object.