Specifying a table name

From InterBase

Go Up to Setting up a table component


The TableName property specifies the table in a database to access with the table component. To specify a table, follow these steps:

  1. Set the table’s Active property to False, if necessary.
  2. Set the DatabaseName property of the database component to a directory path.
Note:
You can use the Database Editor to set the database location, login name, password, SQL role, and switch the login prompt on and off. To access the Database Component Editor, right click on the database component and choose Database Editor from the drop-down menu.
  1. Set the TableName property to the table to access. You are prompted to log in to the database. At design time you can choose from valid table names in the drop-down list for the TableName property in the Object Inspector. At runtime, you must specify a valid name in code.

Once you specify a valid table name, you can set the table component’s Active property to True to connect to the database, open the table, and display and edit data.

At runtime, you can set or change the table associated with a table component by:

  • Setting Active to False.
  • Assigning a valid table name to the TableName property.

For example, the following code changes the table name for the OrderOrCustTable table component based on its current table name:

with OrderOrCustTable do
begin
  Active := False; {Close the table}
  if TableName = 'CUSTOMER.DB' then
    TableName := 'ORDERS.DB'
  else
    TableName := 'CUSTOMER.DB';
  Active := True; {Reopen with a new table}
end;

Advance To: