How to use TQuery

To access a database, set the DatabaseName property to a defined BDE alias, a directory path for desktop database files, or a file name for a server database. If the application has a TDatabase component, DatabaseName can also be set to a local alias that it defines. For more information, see Using the TDatabase component in Chapter 6, Building a client server application. To issue SQL statements with a TQuery component Assign the TQuery component's SQL property the text of the SQL statement....

The SQL property

The SQL property contains the text of the SQL statement to be executed by a Query component. This property is of type TStrings, which means that it is a series of strings in a list. The list acts very much as if it were an array, but it is actually a special class with unique capabilities. For more information on TStrings, see the online VCL reference. A Query component can execute two kinds of SQL statements A static SQL statement is fixed at design time and does not contain any parameters or...

Symbols

+ (plus) sign in property lists 103 + operator 177 operator 177 (colon) in SQL statements 117, 176 < operator 177 < > operator 177 operator 177 > operator 177 (question mark) in SQL statements 176 II operator 177 - (minus) sign in property lists 104 ' (apostrophe), naming conventions 175, 176 abandoning changes 64, 101, 107 Abort procedure 68 AbortOnKeyViol property 92 AbortOnProblem property 92 accessing data 79, 89, 100, 115, 116 at run time 87-88 field values 30, 32 optimizing access...

TDBLookup Combo

The TDBLookupCombo component is similar to TDBComboBox, except that it derives its list of values dynamically from a second dataset at run time, and it can display multiple columns in its drop-down list. With this control, you can ensure that users enter valid values into forms by providing an interface from which they can choose values. Here is an example of how a TDBLookupCombo component appears at run time Figure 4.10 TDBLookupCombo component Figure 4.10 TDBLookupCombo component The lookup...

TDBLookup List

TDBLookupList is functionally the same as TDBLookupCombo, but instead of a drop-down list, it displays a scrollable list of the available choices. When the user selects one at run time, the component is assigned that value. Like TDBLookupCombo, the user cannot type in an entry that is not in the list. Here is an example of how a TDBLookupList component appears at run time While navigating through a dataset, a TDBLookupList component highlights the item in the list that corresponds to the value...

Creating heterogenous queries

Some applications may require queries of tables in more than one database. Such queries are called heterogenous queries, and are not supported by standard SQL. A heterogenous query may join tables on different servers, and even different types of servers. For example, a heterogeneous query might involve a table in a Oracle database, a table in a Sybase database, and a local dBASE table. Delphi supports heterogeneous queries, as long as the query syntax conforms to the requirements of local SQL,...

Using the ParamByName method

ParamByName is a function that enables an application to assign values to parameters based on their names. Instead of providing the ordinal location of the parameter, you must supply its name. For example, an application could use ParamByName could specify values for the parameters in the preceding example as follows Query2.ParamByName 'Name' .AsString 'Liehtenstein' Query2.ParamByName 'Capital' .AsString 'Vaduz' 420000 These statements would have the same effect as the three previous...

Using the Local Inter Base Server

The Local InterBase Server LIBS is a version of the Borland InterBase server that runs on Windows 3.1. It provides all of the features of a SQL server for local, single-user operation. For more information on the Local Interbase Server, see the Local InterBase Server User's Guide. The Local Interbase Server can be used in primarily two ways for client server development As a local environment for developing a client server application, regardless of the server to be used. As an intermediate...

Displaying data as labels with TDBText

TDBText is a read-only control similar to the TLabel component on the Standard page of A the Component palette. TDBText gets the text it displays from a specified field in the current record of a dataset. Because TDBText gets its text from a dataset, the text it displays is dynamic the text changes as the user navigates the database table. Therefore you cannot specify the display text of TDBText at design time as you can with TLabel. When TDBText is linked to a data field at design time,...

Using Drop Index

Local SQL provides the following variation of the ANSI-standard DROP INDEX statement for deleting an index. It is modified to support dBASE and Paradox file names. DROP INDEX table_name.index_name PRIMARY The PRIMARY keyword is used to delete a primary Paradox index. For example, the following statement drops the primary index on EMPLOYEE.DB DROP INDEX employee.db.PRIMARY To drop any dBASE index, or to drop secondary Paradox indexes, provide the index name. For example, the next statement drops...

TDBList Box

TDBListBox is functionally the same as TDBComboBox, but instead of a drop-down list, it displays a scrollable list of available choices. When the user selects a value at run time, the component is assigned that value. Unlike TDBComboBox, the user cannot type in an entry that is not in the list. Here is an example of how a TDBListBox component appears at run time. Figure 4.9 TDBListBox component While navigating through a dataset, a TDBListBox component displays values in the column by...

Advanced Delphi Database Applications

Sample applications LINKQRY 123 MASTAPP 20, 183 TWOFORMS 95 sample database 183-186 saving aliases 172, 173 SQL statements 118, 169 screens flickering 67 redrawing 105, 108, 109 script files 118 scroll bars 108 scroll locks 162 ScrollBars property 108 scrolling through images 109 scrolling through lists 110, 112 scrolling through text 108 search conditions SQL queries 178 search functions 70 search mode 70 searching for data 42-43, 70-72 in unkeyed fields 47 nearest match 71, 72 SECOND constant...