RAD Studio |  |

Using TTable (Procedure)
See Also
Collapse All

TTable is a table-type dataset that represents all of the rows and columns of a single database table.

To use TTable

1. Choose FileNewOther. The New Items dialog appears.
2. In the New Items dialog, select Delphi Projects and double-click VCL Forms Application. The Windows Designer displays.
3. Associate the dataset with the database and session connections.
4. Specify the table type for local tables and control read/write access to local tables.
5. Specify a dBASE index file.
6. Rename local tables.
7. Import data from another table.

To associate a dataset with database and session connections

1. From the BDE category of the Tool Palette, drag a TDatabase component to the form.
2. Drag a TSession component to the form.
3. To associate a BDE-enabled dataset with a database, in the Object Inspector, set the DatabaseName property of the TDatabase component . For a TDatabase component, the database name is the value of the DatabaseName property of the database component.
4. Use the default session to control all database connections in your application.
5. Set the SessionName property of the TSession component to associate your dataset with an explicitly created session component.

If you use a session component, the SessionName property of a dataset must match the SessionName property for the database component with which the dataset is associated.
To specify the TableType and control read/write access

1. From the BDE category of the Tool Palette, drag a TTable component to the form.
2. In the Object Inspector, set the TableType property if an application accesses Paradox, dBASE, FoxPro, or comma-delimited ASCII text tables. BDE uses the TableType property to determine the table’s type.
3. Set TableType to ttDefault if your local Paradox, dBASE, and ASCII text tables use the file extensions like, .DB, .DBF, and .TXT.
4. For other extensions, set TableType to ttParadox for Paradox, ttDBase for dBASE, ttFoxPro for FoxPro, and ttASCII for Comma-delimited ASCII text respectively.
5. Set the table component’s Exclusive property to True before opening the table to gain sole read/write access.
   Note: If the table is already in use when you attempt to open it, exclusive access is not granted. You can attempt to set Exclusive on SQL tables, but some servers do not support exclusive table-level locking. Others may grant an exclusive lock, but permit other applications to read data from the table.

To specify a dBASE index file

1. Set the IndexFiles property to the name of the non-production index file or list the files with a .NDX extension.
2. Specify one index in the IndexName property to have it actively sorting the dataset.
3. At designtime, click the ellipsis button in the IndexFiles property. The Index Files editor opens.
4. To add a non-production index file or file with .NDX extension, click the Add button in the Index Files dialog and select the file from the Open dialog.
   Note: For each non-production index file or .NDX file, repeat Steps 3 and 4.
5. After adding all desired indexes, click the OK button in the Index Files editor.

Note: To do steps 3-5 at runtime, access the IndexFiles property using properties and methods of string lists.
To rename local tables

1. To rename a Paradox or dBASE table at design time, right-click the table component. A drop-down context menu opens.
2. From the context menu, select Rename Table.
3. To rename a Paradox or dBASE table at runtime, call the table’s RenameTable method.

To import data from another table

1. Use the BatchMove method of a table component to import data, copy, update, append records from another table into this table, or delete records from a table.
2. Set the name of the table from which to import data, and a mode specification that determines which import operation to perform.

See Also

BDE Overview

Using TDatabase

Using TSession

Using TQuery

Using TStoredProc

Using TBatchMove

Using TUpdateSQL

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