Читайте также:
|
|
Lecture 13. Using TTable component
TTable is one of the most important database component classes. Along with the otherdataset component class, TQuery, it enables an application to access a database table. This lecture describes the most important properties that are unique to TTable.
Specifying the database table
TableName specifies the name of the database table to which the TTable component islinked. You can set this property at design time through the Object Inspector.
The DatabaseName property specifies where Delphi will look for the specified database table. It can be a BDE alias, an explicit specification, or the DatabaseName defined by any TDatabase component in the application. For Paradox and dBASE tables, an explicitspecification is a directory path; for SQL tables, it is a directory path and database name.
Instead of an actual directory path or database name, DatabaseName can also be a BDE alias. The advantage of this is that you can change the data source for an entire application by simply changing the alias definition in the BDE Configuration Utility.
Note Neither of these properties can be changed when a table is open—that is, when the table’s Active property is set to a value of True.
The TableType property
The TableType property specifies the type of the underlying database table. This property is not used for SQL tables.
If TableType is set to Default, the table’s file-name extension determines the table type:
• Extension of.DB or no file-name extension: Paradox table
• Extension of.DBF: dBASE table
• Extension of.TXT: ASCII table
If the value of TableType is not Default, then the table will always be of the specified TableType, regardless of file-name extension.
Searching a table
TTable has a number of functions that will search for values in a database table:
• Goto functions
• Find functions
The easiest way to search for values is with the Find functions, FindKey and FindNearest. These two functions combine the functionality of the basic Goto functions, SetKey, GoToKey, and GoToNearest, which are described first.
In dBASE and Paradox tables, these functions can search only on index fields. In SQL tables, they can search on any fields, if the field name is specified in the IndexFieldNames property of the TTable. For more information, see “Indexes” on page 74.
To search a dBASE or Paradox table for a value in a non-index field, use SQL SELECT syntax with a TQuery component. For more information on using SQL and TQuery components, see Chapter 5, “Using SQL in applications.”
Дата добавления: 2015-10-23; просмотров: 110 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Lecture 9. Using Data Controls | | | Using TDataSource events |