Tuesday, 23 March 2010

Delphi - Interbase Tutorial # 6 : Query

In Delphi, you can also use SQL to access your data. You have to use Query component that is in the Data Access Page of the component palette.

First, create a user interface like picture shown below :

Set the properties of the components

DataSource1

DataSetQuery1

Button1

Caption&G O

DBGrid1

DataSourceDataSource1

Query1

DatabaseNameALIASMYDATA
SQLselect * from employee where age >=30

You have to type the SQL code in the String List editor of Query component, see the picture below :

Type the code below for the OnClick event of  the GO button :

procedure TForm1.Button1Click(Sender: TObject);
begin
Query1.Open;
end; 

What is the meaning of Query1.Open  ?

This statement activate the Query and execute the SQL statement in SQL property of Query1. The result is like the picture shown below :

You can also add an exit button into the user interface above.

Go to Previous Tutorial or Next Tutorial

0 comments:

Post a Comment

These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.