KA Dao Queries

KA Dao is a freeware component that provides access to MS Access without using the BDE.

However, the provided help is a little weak. This page helps to fill in a few holes. Since both TKADaoTable and TTable are derived from TDataSet, there are many similarities.

This documents covers those query techniques that are NOT the same.

Note:

Functions that Work the Same | Find_First | FindFirst | Select query | SQL Property | Filter Property


Functions that Work the Same

These query-type functions work the same for TKADaoTable and TTable.


Find_First, et al.

Find_First is a type of query used with a TKADaoTable.

Find_First finds the first record - related commands Find_Next Find_Prior Find_Last


FindFirst, et al.

Find_First is a type of query used with all TDataset descendants ... including TKADaoTable. The only difference is that before calling one of these functions you must call SetFindData method.

This example (from the KA Dao help) should show the data on a form.


Select query

There are basically 2 types of queries

Strings inside a query are surrounded with double quotes because the target is an MS Access database ... for a real SQL database, single quotes should be used.

Set SQL to the following string (the trailing semicolon is optional)

For the error is
Project xyz raised exception class EOleException with message 'Cannot execute a select query'. Process stopped. Use Step or Run to continue.


Using a query as the table name

Here is another approach This works


Implementation

eventually calls Which explains why select cannot be executed.

On the otherhand, using a select query as a table name eventually calls

which is ok. Note that dbOpenDynaset is defined in DAOApi, which, therefore, must be included in the uses clause.


KADaoTable SQL Property

The KADaoTable SQL Property provides another way to perform a select query.

In this example, :Group_ID_Parameter is read from the Params property.

Set the KADaoTable.SQL property to

Notice that where clauses are normally formatted with double quotes around a string. However, when parameter substitution is used, the double quotes must NOT be present (the object handles it correctly). Assuming that KADaoTable.ParamCheck is true (the default), a TParam property is automatically created for each phrase in the SQL property that starts with a colon.

The following sucessfully sets the parameter and queries the database.

The help says to use the open method, but that does not work.


KADaoTable Filter Property

When Filtered is True and KADaoTable.Filter text is changed the Table automatically refreshes its contents.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Databases / Delphi / KADao_Queries.html