RAD Studio
ContentsIndex
PreviousUpNext
Connecting Directly to a Database Server

The most common database architecture is the one where the dataset uses a connection component to establish a connection to a database server. The dataset then fetches data directly from the server and posts edits directly to the server. This is illustrated in the following figure. 

Connecting directly to the database server 

 

Each type of dataset uses its own type of connection component, which represents a single data access mechanism:

  • If the dataset is a BDE dataset such as TTable, TQuery, or TStoredProc, the connection component is a TDataBaseobject. You connect the dataset to the database component by setting its Databaseproperty. You do not need to explicitly add a database component when using BDE dataset. If you set the dataset's DatabaseName property, a database component is created for you automatically at runtime.
  • If the dataset is an ADO dataset such as TADODataSet, TADOTable, TADOQuery, or TADOStoredProc, the connection component is a TADOConnectionobject. You connect the dataset to the ADO connection component by setting its Connectionproperty. As with BDE datasets, you do not need to explicitly add the connection component: instead you can set the dataset's ConnectionStringproperty.
  • If the dataset is a dbExpress dataset such as TSQLDataSet, TSQLTable, TSQLQuery, or TSQLStoredProc, the connection component is a TSQLConnection object. You connect the dataset to the SQL connection component by setting its SQLConnection property. When using dbExpress datasets, you must explicitly add the connection component. Another difference between dbExpress datasets and the other datasets is that dbExpress datasets are always read-only and unidirectional: This means you can only navigate by iterating through the records in order, and you can't use the dataset methods that support editing.
  • If the dataset is an InterBase Express dataset such as TIBDataSet, TIBTable, TIBQuery, or TIBStoredProc, the connection component is a TIBDatabaseobject. You connect the dataset to the IB database component by setting its Database_Database">Databaseproperty. As with dbExpress datasets, you must explicitly add the connection component.
In addition to the components listed above, you can use a specialized client dataset such as TBDEClientDataSet, TSimpleDataSet, or TIBClientDataSet with a database connection component. When using one of these client datasets, specify the appropriate type of connection component as the value of the DBConnection property. 

Although each type of dataset uses a different connection component, they all perform many of the same tasks and surface many of the same properties, methods, and events. For more information on the commonalities among the various database connection components, see Connecting to databases 

This architecture represents either a single-tiered or two-tiered application, depending on whether the database server is a local database such or a remote database server. The logic that manipulates database information is in the same application that implements the user interface, although isolated into a data module.

Note: The connection components or drivers needed to create two-tiered applications are not available in all version of Delphi.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!