RAD Studio
ContentsIndex
PreviousUpNext
Database Procedures

This topic describes how to use the database components in the Tool Palette, like dbGo components, dbExpress components, BDE components, and DataSnap components.

Name 
Description 
The schema information or metadata includes information about what tables and stored procedures are available on the server and the information about these tables and stored procedures (like the fields of a table, the indexes that are defined, and the parameters a stored procedure uses). 
Before you have a connection, you can use Data Explorer to assemble connection strings. 
The first step when working with a unidirectional dataset is to connect it to a database server. At designtime, once a dataset has an active connection to a database server, the Object Inspector can provide drop-down lists of values for other properties. For example, when representing a stored procedure, you must have an active connection before the Object Inspector can list what stored procedures are available on the server. The connection to a database server is represented by a separate TSQLConnection component. You work with TSQLConnection like any other database connection component. 
A client application uses one or more connection components in the DataSnap category of the Tool Palette to establish and maintain a connection to an application server. 
While you are debugging your database application, you can monitor the SQL messages that are sent to and from the database server through your connection component, including those that are generated automatically for you (for example by a provider component or by the dbExpress driver). 
You can use a unidirectional dataset even if the query or stored procedure it represents does not return any records. Such commands include statements that use Data Definition Language (DDL) or Data Manipulation Language (DML) statements other than SELECT statements. The language used in commands is server-specific, but usually compliant with the SQL-92 standard for the SQL language. The SQL command you execute must be acceptable to the server you are using. Unidirectional datasets neither evaluate the SQL nor execute it, but pass the command to the server for execution. 
 
 
Client datasets are specialized datasets that hold all the data in memory. They use a provider to supply them with data and apply updates when they cache updates from a database server or another dataset, represent the data in an XML document, and store the data in the client portion of a multi-tiered application. 
 
A multi-tiered client/server application is partitioned into logical units, called tiers, which run in conjunction on separate machines. Multi-tiered applications share data and communicate with one another over a local-area network or even over the Internet. They provide many benefits, such as centralized business logic and thin client applications.
Multi-tiered applications use the components on the DataSnap category in the Tool Palette. DataSnap provides multi-tier database capability to Delphi applications by allowing client applications to connect to providers in an application server. 
TBatchMove copies a table structure or its data. It can be used to move entire tables from one database format to another. 
TDatabase sets up a persistent connection to a database, especially a remote database requiring a user login and password. TDatabase is especially important because it permits control over database transaction processing with the BDE when connected to a remote SQL database server. Use TDatabase when a BDE-based database application requires:
  • Persistent database connections
  • Customized database server logins
  • Transaction control
  • Application-specific BDE aliases
 
TQuery is a query-type dataset that encapsulates an SQL statement and enables applications to access the resulting records. 
TSQLQuery represents a query that is executed using dbExpress. TSQLQuery can represent the results of a SELECT statement or perform actions on the database server using statements such as INSERT, DELETE, UPDATE, ALTER TABLE, and so on. You can add a TSQLQuery component to a form at design time, or create one dynamically at runtime. 
TSQLStoredProc represents a stored procedure that is executed using dbExpress. TSQLStoredProc can represent the result set if the stored procedure returns a cursor. You can add a TSQLStoredProc component to a form at design time, or create one dynamically at runtime. 
TSQLTable represents a database table that is accessed using dbExpress. TSQLTable generates a query to fetch all of the rows and columns in a table you specify. You can add a TSQLTable component to a form at designtime, or create one dynamically at runtime. 
A session provides global connection over a group of database components. A default TSession component is automatically created for each database application. You must use TSession component only if you are creating a multithreaded database application. Each database thread requires its own session components. 
TSimpleDataSet is a special type of client dataset designed for simple two-tiered applications. Like a unidirectional dataset, it can use an SQL connection component to connect to a database server and specify an SQL statement to execute on that server. Like other client datasets, it buffers data in memory to allow full navigation and editing support. 
If you have multiple COM-based servers that your client application can choose from, you can use an Object Broker to locate an available server system. 
TStoredProc is a stored procedure-type dataset that executes a stored procedure that is defined on a database server. 
TTable is a table-type dataset that represents all of the rows and columns of a single database table. 
When the BDE-enabled dataset represents a stored procedure or a query that is not “live”, it is not possible to apply updates directly from the dataset. Such datasets may also cause a problem when you use a client dataset to cache updates. 
 
You can add new connections to the Data Explorer, which persist as long as the connection object exists. 
Once you have a live connection, you can use the Data Explorer to browse database objects. 
You can write, edit, and execute SQL in an SQL Window, which is available from within the Data Explorer
You can modify connections in a variety of ways from the Data Explorer
This procedure tells how to use the dbExpress driver framework to connect to a database and read its records. In the sample code, the dbExpress ini files contain all the information about the particular database connection, such as driver, user name, password, and so on. 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!