General instructions for setting up a Table, DataSource and DbGrid component at design time in order to access the data encapsulated by a table component.
Difficulty Level: easy Time Required: 5 minutes
Here's How:
- Start Delphi and select File | New Application...
- Select Data Access page on the Component palette.
- Place one TTable component on a form.
- Place one TDataSource component on a form.
- Select Data Controls page on the Component palette.
- Place one TDbGrid component on a form.
- Set the DatabaseName of the TTable component (Table1) to the name of the database to access. Select DBDemos.
- Set the TableName property to the name of the table in the database. Select customer.db
- Select TDataSource (DataSource1) component and set DataSet property to the name of the table component, that is: Table1.
- Select TDbGrid (DBGrid) component and set the DataSource property to the name of the data source component, i.e. DataSource1.
- Set the Active property of the table component to True.
- Browse through the records.
- A table component always references a single database table. If you need to access multiple tables with a single component, you should use a query component instead of a table component.
- There are two ways to close a table. You can set its Active property to False, or you can call its Close method. Active controls associated with the tables data source are cleared (e.g. DbGrid1).
Related Features:
- Database Form Wizard - Developing my own, first Delphi database application, using Database Form Wizard.
- Coloring DBGrid - How to enhance the functionality of a TDBgrid component using colors.
- More Delphi Programming HOW TOs

