Recent

Author Topic: TSQLQuery post causes error 'Database is locked'  (Read 923 times)

panoss

  • Full Member
  • ***
  • Posts: 156
  • You only live twice
TSQLQuery post causes error 'Database is locked'
« on: August 08, 2018, 06:26:55 pm »
I 'm trying to insert a new record with this code:
Code: Pascal  [Select]
  1.   partsperdevice_qry.Append;
  2.   partsperdevice_qry.FieldByName('device_id').AsInteger:= 1;
  3.   partsperdevice_qry.FieldByName('part_id').AsInteger:=3;
  4.   partsperdevice_qry.Post;  
  5.  
At .post I get the error: 'database is locked'. (I delete the db and recreate witn SQL, so if it 's locked it gets 'unlocked' for sure)
I guess I 'm doing something wrong?
Windows 7 32bit, Lazarus v1.8.4    FPC 3.0.4.

mangakissa

  • Hero Member
  • *****
  • Posts: 865
Re: TSQLQuery post causes error 'Database is locked'
« Reply #1 on: August 08, 2018, 08:20:33 pm »
I tried to start the engine of my car, but can't ride forward.
Thats excatly what you saying ;)

So
- which database
- are you meaning the table or database it self.
- SQLdb, ZEOS or another databaseframework
- How did you create your DB/table

As far as I can tell you is: where is the commit(retaining)?
Read the database tutorials (even if it's ZEOS)
 
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

af0815

  • Full Member
  • ***
  • Posts: 172
Re: TSQLQuery post causes error 'Database is locked'
« Reply #2 on: August 08, 2018, 09:01:48 pm »
And don't use two connection for one DB if you use a desktop DB.
regards
Andreas

panoss

  • Full Member
  • ***
  • Posts: 156
  • You only live twice
Re: TSQLQuery post causes error 'Database is locked'
« Reply #3 on: August 08, 2018, 10:10:05 pm »
I tried to start the engine of my car, but can't ride forward.
Thats excatly what you saying ;)

So
- which database
- are you meaning the table or database it self.
- SQLdb, ZEOS or another databaseframework
- How did you create your DB/table

As far as I can tell you is: where is the commit(retaining)?
Read the database tutorials (even if it's ZEOS)
Sorry I was in a hurry, that 's why I forgot some basic things.


The error is 'Database is locked', so I mean the database.
SQLite.
I created it with 'DB Browser for SQLite' version 3.10.1.


And don't use two connection for one DB if you use a desktop DB.
I only have one connection.

EDIT: I recreated the db with the SQL and this time it worked! No locks anymore!
I don' t know what the problem was as I did nothing differently this time...
« Last Edit: August 08, 2018, 10:35:25 pm by panoss »
Windows 7 32bit, Lazarus v1.8.4    FPC 3.0.4.

egsuh

  • Full Member
  • ***
  • Posts: 174
Re: TSQLQuery post causes error 'Database is locked'
« Reply #4 on: August 09, 2018, 01:16:21 am »
Once I had similar experience with SQLite3. I don't know why yet. Just guessing that DB Browser for SQLite might have been open at the same time, something like that.