Recent

Author Topic: (SOLVED) Database is locked (SQLlite 3 and TSQLTransaction)  (Read 6022 times)

washburn_it

  • New Member
  • *
  • Posts: 29
(SOLVED) Database is locked (SQLlite 3 and TSQLTransaction)
« on: April 26, 2016, 04:40:29 pm »
Hi,

I have a simple SQLite database and a table where there is an "ID" field that I write incrementing by 1 at each INSERT INTO.
So to have the new ID I simply query "SELECT MAX(ID) FROM USR_TRANSAZ" and the result is the new ID that I will write with "INSERT INTO USR_TRANSAZ(ID, TRANSAZ)........" (I omitted the whole query since it's very simple).
Not everytime but often when the "TSQTransaction.Commit" is executed I get "Database is locked" error.
It's the only task running so I can't see where is the mistake: is it because I'm inserting a record into a table previously opened with a SELECT?
I'm used to program using SQL Server (under Windows) where I never faced this problem.
Thank you, regards.

Roberto
« Last Edit: April 28, 2016, 09:15:47 am by washburn_it »

LacaK

  • Hero Member
  • *****
  • Posts: 696
Re: Database is locked (SQLlite 3 and TSQLTransaction)
« Reply #1 on: April 27, 2016, 07:25:13 pm »
If you use only one connection from one application such error should not happen.
So it leads me to an idea, that there must be simultaneous connection to same database file.
When you try "Commit" SQLite is trying write to database, but when encounters that file is accessed also by other connection then throws mentioned error.

washburn_it

  • New Member
  • *
  • Posts: 29
Re: Database is locked (SQLlite 3 and TSQLTransaction)
« Reply #2 on: April 28, 2016, 08:57:14 am »
Not being able to find the problem I created two connections: one to read data and one to write data.
The problem seems fixed since the error didn't appear anymore.
Thanks for the reply.
Regards,


Roberto

« Last Edit: April 28, 2016, 09:15:25 am by washburn_it »

 

TinyPortal © 2005-2018