Tutorial Delphi 7
Tutorial Delphi 7
8. FILTER RESULTS
8.1 Filter according to exact search criteria (e.g. Name = 'John'):
8.2 Filter according to similar search criteria (e.g. Name LIKE 'Jo%'):
11. QUERIES
11.1 Set up query
11.1.1 Create database file in MS Access
11.1.2 In Delphi: choose ADOQuery under the ADO menu on the component palette
11.1.3 Change settings in Object Inspector: set Connection String settings by clicking on the ellipse
11.1.4 Click on Build…
11.1.5 Choose: Microsoft Jet 4.0 OLE DB Provider
11.1.6 Click Next >>
11.1.7 Select database file (mdb file)
11.1.8 Erase user name (‘Admin’)
11.1.9 Make sure 'Blank Password' is selected
11.1.10 Click OK (on 'Data Link Properties' window)
11.1.11 Click OK (on 'ConnectionString' window)
11.2.3 Show all fields for records meeting certain exact criteria
Select * from tblTableName where Name = "John ";
11.2.5 Show all fields and all records sorted according to a field (ascending)
Select * from tblTableName order by Name;
11.2.6 Show all fields and all records sorted according to a field (descending)
Select * from tblTableName order by Name DESC;
11.2.7 Show all fields and all records within a set range (Unit is an Integer field)
Select * from tblTableName where Unit between 1 and 6;
11.4 Change data (Amount field becomes 10) according to a condition (Unit equals to 4)
procedure TForm1.Button3Click(Sender: TObject);
begin
with ADOQuery1 do
begin
Active := false;
SQL.Clear;
SQL.Add('Update tblTableName');
SQL.Add('set Amount = 10 where Unit = 4');
ExecSQL
end;
ADOTable1.Refresh;
end;