Grade 12 · Practical
Databases in Delphi
Programming Fundamentals · about 3 min
Paper 1 Section B pairs SQL with Delphi database code. The Delphi side navigates and edits a connected table.
Key points- Components: `TADOConnection` (the database), `TADOTable`/`TADOQuery` (the data), `TDataSource` (to controls).
- The core loop: `tbl.First; while not tbl.Eof do begin if condition then action; tbl.Next; end;`.
- Edit a field: `tbl.Edit; tbl['field'] := value; tbl.Post;`. Append: `tbl.Append; … tbl.Post;`.
- After `tbl.Delete` do NOT call `tbl.Next` — the cursor already moves.
- Dataset — a TADOTable/TADOQuery exposing table rows to the program.
- Post — commit the current edit/append to the database.
EXAM TIP
Q2.1 is SQL only, Q2.2 is Delphi only — don't mix them; the Delphi answer is always First → while not Eof → action → Next.