JohnLM 14 Posted January 1, 2023 (edited) From time to time, I want to be able to quickly view/verify databases that I'm working on but from another app. In XE7, I have a db app that I created for sqlite databases. I drag the file.db to the app and it opens and displays the data, but i'm having trouble making that happen when I am in delphi d11 project and its giving me the 'database is locked' error. Even when I uncheck [ ] the 'Connected' setting in Object Inspector. I seem to recall a step to set the project's app to share or something like that but can't find it or the feature to allow an open database to be shared or opened (for viewing only) from another app. Is this still possible, and how ? Edited January 1, 2023 by JohnLM Share this post Link to post
programmerdelphi2k 237 Posted January 1, 2023 (edited) better read this https://www.sqlite.org/lockingv3.html Quote 5.0 Writing to a database file To write to a database, a process must first acquire a SHARED lock as described above (possibly rolling back incomplete changes if there is a hot journal). After a SHARED lock is obtained, a RESERVED lock must be acquired. The RESERVED lock signals that the process intends to write to the database at some point in the future. Only one process at a time can hold a RESERVED lock. But other processes can continue to read the database while the RESERVED lock is held. If the process that wants to write is unable to obtain a RESERVED lock, it must mean that another process already has a RESERVED lock. In that case, the write attempt fails and returns SQLITE_BUSY as an Embedded DB, it's not allowed more than 1 app access it. when using IDE or debugging, 1 connection will be used for all actions on db. Edited January 1, 2023 by programmerdelphi2k Share this post Link to post
programmerdelphi2k 237 Posted January 1, 2023 (edited) another way, you can try this: all apps should have this param by default: LockingMode=Normal (including IDE) you'll need a refresh for all updates in another apps! procedure TForm1.Button3Click(Sender: TObject); var i: integer; begin FDConnection1.Close; Memo1.Text := FDConnection1.Params.Text + slinebreak; // i := FDConnection1.Params.IndexOfName('LockingMode=Exclusive'); if (i > -1) then FDConnection1.Params[i] := 'LockingMode=Normal' else FDConnection1.Params.Add('LockingMode=Normal'); // Memo1.Lines.Add(FDConnection1.Params.Text); end; // or simply... FDConnection1.Params.Values['LockingMode'] := 'Normal'; Edited January 1, 2023 by programmerdelphi2k Share this post Link to post