rvk:
What does that code do?
So what are you trying to do there?
I found this piece of code here in this forum several years ago when I was looking for a solution to the 'database locked' error. It was suppose to be the answer to this problem so that is why I included it.
If on the other hand you have connected set to true in your IDE then THAT is the cause of your locked file.
Because then the IDE/Lazarus has the file open at design time and you open it again at run time.
I did indeed have the SQLite3Connection1 set to active. So I now have SQLite3Connection1, SQLQuery1, and Transaction1 all set to active false. I do have the code below:
procedure TDataModule1.DataModuleCreate(Sender: TObject);
var
strDbName: string;
begin
strDbName := SysUtils.ExtractFilePath(ParamStr(0)) + 'data.sqlite3';
DataModule1.SQLite3Connection1.DatabaseName := strDbName;
end;
It is working great now, thank you rvk for your help!
egsuh:
If Datamodule is auto-created, you don't have to create TSQLQuery within the DatamoduleCreate event if you dropped it from component palette.
Transaction should be started before any action on the database is done. So,
Transaction1.StartTransaction; or Transaction1.Active := true; should precede
SQLQuery1.Open; or SQLQuery1.ExecSQL;
And then you call
Transaction1.Commit;
Now that makes since, thank you!