Page 1 of 1

Getting Lock State

Posted: Thu 28 Feb 2019 08:11
by davor.TCS
I have two application's that use same db file. 1st application is service and it always writes data in db file. Second application is GUI in which you set initial values in same db file. However when i try to write to db file I get Error 5 (database is locked).
1. Is there any way to share file between two applications?
2 How can I detect who has lock write on db file?

Re: Getting Lock State

Posted: Fri 05 Apr 2019 08:42
by MaximG
1. When the same SQLite file is used by several applications, first of all, you need to follow the description provided at the project web site: https://www.sqlite.org/lockingv3.html
The occurrence of the SQLITE_BUSY error is always related to the competing access to DB since SQLite supports only one writer at a time. Thus, normally you need to process this error in the code of the application being developed according to the business logic of its work. To minimize the number of SQLITE_BUSY errors, you can try using the WAL (sqlite.org/wal.html) mode. To enable this mode in LiteDAC, you can do the following:

Code: Select all

LiteConnection.ExecSQL('PRAGMA journal_mode=WAL');
Besides, you can set the suggested wait time out with the BusyTimeout option: https://www.devart.com/litedac/docs/dev ... imeout.htm
2. Our components do not provide access to the information you inquired about.

Re: Getting Lock State

Posted: Sun 07 Apr 2019 06:18
by davor.TCS
Busy timeout solved the problem. I did not mention, this application is basically in one exe file. This exe file can be installed as service (then it collects data and writes it in DB file) and as GUI application (then you can set options and view data). Problem was when both try to write data at the same time.
Also, service is behaving very strangely.
At Windows XP on starting computer Service starts (I can stop it, and start it, no problem).
But on OS > Windows 7 Service will not start on starting computer (I can stop it, and start it, no problem)?
I know this is of topic, but if you have any suggestion, please share.

Thank you.

Re: Getting Lock State

Posted: Wed 10 Apr 2019 10:09
by MaximG
The described behavior is not related to the behavior of our product. The solution of this issue can be found by using specialized forums.

Re: Getting Lock State

Posted: Thu 11 Apr 2019 10:07
by davor.TCS
True. Thanks.