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.
- 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 table’s data source are cleared (e.g. DbGrid1).
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου