Παρασκευή 11 Μαΐου 2012

How to Create a Simple Database Display Form

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. 


  1. Start Delphi and select File | New Application...
  2. Select Data Access page on the Component palette.
  3. Place one TTable component on a form.
  4. Place one TDataSource component on a form.
  5. Select Data Controls page on the Component palette.
  6. Place one TDbGrid component on a form.
  7. Set the DatabaseName of the TTable component (Table1) to the name of the database to access. Select DBDemos.
  8. Set the TableName property to the name of the table in the database. Select customer.db
  9. Select TDataSource (DataSource1) component and set DataSet property to the name of the table component, that is: Table1.
  10. Select TDbGrid (DBGrid) component and set the DataSource property to the name of the data source component, i.e. DataSource1.
  11. Set the Active property of the table component to True.
  12. Browse through the records. 
Tips:
  1. 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.
  2. 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).

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου