I had managed to have a closer looksee

1. seems you manually added some entries in the form type declaration.
HINT: never do that.
If required to manually add components do that in a separate section of the type declaration instead. Either in the public, protected or private sections.
Therefor remove the (commented) entry SQLite3COUNTRIES and the entry SQLTransactionCntries
2. remove the variable declarations DBCntriesConnect, DBCntriesTrans and DBCntriesQry that are situated right beneath the FrmCntriesMgt variable declaration.
Either place the required components on the form (as was already done) or declare them as either fields (in section private, protected or public) or as you did as global variables. Never do both (don't even think about doing it threefold

).
3. Create/add a new private procedure with proto-type "procedure SetupDB;" in the form type declaration, e.g.:
TFrmCntriesMgt = class(TForm)
BitBtnClose: TBitBtn;
DSCntries: TDataSource;
DBGridCntries: TDBGrid;
DBNavCntries: TDBNavigator;
PnlTop: TPanel;
DBCntriesConnect: TSQLite3Connection;
DBCntriesQry: TSQLQuery;
DBCntriesTrans: TSQLTransaction;
procedure BitBtnCloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure SetupDB;
public
end;
When added, position the cursor on that new procedure and press ctrl+shift+c. The method should be then automatically be added to the form implementation section.
Add the following code to that implementation so that it reads:
procedure TFrmCntriesMgt.SetupDB;
var
DBName : string = 'CNTRIESDB.sqlite3';
begin
// References:
// - https://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html
// Step 1: a connection requires a (file)name (and optional credentials).
// ToDo : make sure the file exists.
DBName := SysUtils.ExtractFilePath(ParamStr(0)) + DBName;
DBCntriesConnect.DatabaseName:= DBName;
// Step 2: A transaction require a connection.
DBCntriesTrans.DataBase := DBCntriesConnect;
// At this point the database (connection) /can/ be opened (or connected)
// We open it here just for lolz but it is better to do it after the
// form was created so that feedback can be provided (f.i when things go wrong)
DBCntriesConnect.Open;
// or alternative: DBCntriesConnect.Connected := True;
// Step 3a: Setup Query - a Query requires a database connection
DBCntriesQry.DataBase := DBCntriesConnect;
// Step 3b: Setup Query - a Query requires a transaction
DBCntriesQry.Transaction := DBCntriesTrans;
// Step 4: Setup your data sources
// This can be done at any time it does not specifically has to be step 4.
// Already (properly) done at design time
end;
4. Remove all existing code from the form create event and make a call to procedure SetupDB instead so that it reads:
procedure TFrmCntriesMgt.FormCreate(Sender: TObject);
begin
SetupDB;
end;
5. Change the FormShow event implementation so that it reads:
procedure TFrmCntriesMgt.FormShow(Sender: TObject);
begin
DBCntriesQry.SQL.Text:= 'select * from COUNTRIESDB';
DBCntriesQry.Open;
end;
6. Change the BitBtnCloseClick event implementation so that it reads:
procedure TFrmCntriesMgt.BitBtnCloseClick(Sender: TObject);
begin
try
DBCntriesQry.Close;
finally
DBCntriesConnect.Close(true); // alternatively: DBCntries.Connected:= False;
end;
FrmCntriesMgt.Close;
// Please do not shoot yourself in the foot
// Here the commented code literally removes the ground it stands on
// FrmCntriesMgt.Free;
end;
That should do it. Again I mention, except for the fields showing TMemo in the grid.
PS: Just keep in mind that the sqlite database contains all the tables so that only a single connection and transaction is required (though you could use multiple transactions if wanted). That was also one of the reasons in my previous answer to use global variables (or at least globally accessible) for at least the connection and transaction.