SQLite Database Tutorial: GuitarClub, part 1
Structure of the database and the table
Let's start with a simplified version, that contains only one table.
The database GuitarClub.db contains a table named Members, with the details of each club member. Its columns (aka "fields")
are defined as follows:
Note: for SQLite, the type VARCHAR is the same as the type TEXT. It is only important for some components of Lazarus. We'll come back to this later on.
GuitarClub project with 1 table
For this project, create a folder FPlaz\SQLite01, download SQLite01.zip and
unzip to this folder.
- Start Lazarus and open project SQLite01.
- Compile and run the application (press F9).
Below is a snapshot of the application at runtime:
- Play a while with the application: navigate through the grid by using the DBNavigator, modify records, add records,
- Stop the program.
When you look at the source code, it is surprisingly short:
procedure TForm1.FormShow(Sender: TObject);
SQLTransaction1.Active := True;
However, most of the functionality was set up in the Object InSpector.
Let's have a look at the components at design time:
Property SQL defines which rows and columns are shown in the grid.
||select * from members order by|
Fieldname: Lastname; Width: 120
Fieldname: Firstname; Width: 120
Fieldname: ID; Width: 50