TQuery and RequestLive in Delphi 7

TQuery component in Delphi enables your applications to use SQL syntax to access data from the database like paradox,Oracle etc.

We perform the following steps to use the TQuery component .

1. Create the TQuery Component.This can be done either by dropping the component on top the designer or during the runtime

Eg :


Query1 : TQuery;

Query1 := TQuery1.Create(nil);

2. Set the DatabaseName property of the TQuery to the one that we use.

3. Add the query to the component.The query can be one that produces resultset and that dont.This is added via the property SQL.Text property of the TQuery component .

Query1.SQL.Text := 'Select name from employeetable';

4. Open the Query .

Now that we have the resultset ,we set the datasource of the DBGrid bound to the Query1 .This displays the data in the Grid .

Note that the resultset returned by the TQuery component’s Query (select statement ) is currently “ReadOnly”,where the user cannot edit the data in the Grid that has this resultset bound to it .

This is where the RequestLive property comes in to picture and helps us to make the Resultset returned as editable .

When the RequestLive property is set to true,the results are live that works similar to the TTable component where the user can edit data and when posted will immediately be updated in the database .

The query ‘select name from employeetable’ worked fine when i used it for the Paradox database,But the same query with the oracleDB and the RequestLive set to true resulted in the error “Table/View does not exist.”

This can be resolved by changing the tablename and the column names in the query to the Uppercase letters .

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

Column Alias and Square brackets in SQL Query.
When we want to specify a alias for a column in SQL Query , we tend to use the double quotes or sing...
Delphi 1 to XE7: 20 Years of Continuous Innovation by David I
Here's a video on Delphi 1 to XE7: 20 Years of Continuous Innovation by David I which talks about th...
How to get the MAX row with group by in LINQ query using C# ?
Below is a sample code snippet demonstrating how to retreive the max row with the group by in LINQ Q...