RAD Studio |  |

Building a VCL Forms dbExpress Database Application
See Also
Collapse All

The following procedure describes how to build a dbExpress database application.

Building a VCL Forms dbExpress application consists of the following major steps:

1. Set up the database connection.
2. Set up the unidirectional dataset.
3. Set up the data provider, client dataset, and data source.
4. Connect a DataGrid to the connection components.
5. Run the application.

To add a dbExpress connection component

1. Choose FileNewOtherDelphi Projects or C++Builder Projects and double-click the VCL Forms Application icon. The VCL Forms Designer is displayed.
2. From the dbExpress page of the Tool Palette, place a TSQLConnection component on the form.
3. Double-click the TSQLConnection component to display the Connection Editor.
4. In the Connection Editor, set the Connection Name field to IBConnection.
5. In the Connections Setting box, specify the path to the InterBase database file called employee.gdb in the Database field. By default, the file is located in C:\Program Files\Common Files\Borland Shared\Data.
6. Accept the value in the User_Name field (sysdba) and Password field (masterkey).
7. Click OK to close the Connection Editor and save your changes.

To set up the unidirectional dataset

1. In the Tool Palette on the dbExpress page, place a TSQLDataSet component at the top of the form.
2. In the Object Inspector, select the SQLConnection property drop-down list. Set it to TSQLConnection1.
3. Set the CommandText property to an SQL command, for example, Select * from SALES. You are prompted to log in. Use the masterkey password. For the SQL command, you can either type a Select statement in the Object Inspector or click the ellipsis to the right of CommandText to display the CommandText Editor where you can build your own query statement.
   Tip: If you need additional help while using the CommandText Editor
   , click the Help button.
4. In the Object Inspector, set the Active property to True to open the dataset.

To add the provider

1. In the Tool Palette on the Data Access page, place a TDataSetProvider component at the top of the form.
2. In the Object Inspector, select the DataSet property drop-down list. Set it to SQLDataSet1.

To add client dataset

1. In the Tool Palette on the Data Access page, place a TClientDataSet component to the right of the TDataSetProvider component on the form.
2. In the Object Inspector, select the ProviderName drop-down. Set it to DataSetProvider1.
3. Set the Active property to True to allow data to be passed to your application. A data source connects the client dataset with data-aware controls. Each data-aware control must be associated with a data source component to have data to display and manipulate. Similarly, all datasets must be associated with a data source component for their data to be displayed and manipulated in data-aware controls on the form.

To add the data source

1. In the Tool Palette on the Data Access page, place a TDataSource component to the right of the TClientDataSet on the form.
2. In the Object Inspector, select the DataSet property drop-down. Set it to ClientDataSet1.

To connect a DataGrid to the DataSet

1. In the Tool Palette on the Data Controls page, place a TDBGrid component on the form.
2. In the Object Inspector, select the DataSource property drop-down. Set the data source to DataSource1.
3. ChooseRunRun. You are prompted to enter a password. Enter masterkey. If you enter an incorrect password or no password, the debugger throws an exception. The application compiles and displays a VCL form with a DBGrid.

See Also

VCL Overview

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!