I am creating Firemonkey Desktop Application with local SQLite Database (using Delphi XE4 Professional), but database do not work properly. There is no probelm, when I am inserting some data into database, but when I am trying to execute some other SQL commands on my database (especially DELETE and SELECT), I retrieve message "Database is locked" or something like "' 7 ' is not a valid integer value".
In my application I've used TSQLConnection, TSQLQuery, TDataSetProvider and TClientDataSet components to connect to my database. Everything is connected to existing database just like in this video http://www.youtube.com/watch?v=ljdo0yUNVmA only difference is, that my database isn't InterBase, but SQLite.
Database is created with SQLite3.7.11 from cmd
CREATE TABLE History (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Kod TEXT( 7 ));
CREATE TABLE Drogs (
Kod TEXT( 7 ) PRIMARY KEY,
Naz TEXT( 60 ),
Dop TEXT( 60 ),
RegCis TEXT( 20 ),
ATC TEXT( 8 ),
Hraz TEXT( 1 ),
Obch TEXT( 1 ));
After connecting database to my application (as described above), data are inserted into table Drogs
sKod := quotedstr('1234567');
sNaz := quotedstr('Name');
sHraz := quotedstr('0');
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('INSERT INTO Drogs (Kod, Naz, Hraz) ');
SQLQuery1.SQL.Add('VALUES('+sKod+','+sNaz+','+sHraz+')');
SQLQuery1.ExecSQL;
This works without problems, but this code
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('SELECT * from Drogs');
SQLQuery1.Open;
gives error message like
'7 ' is not a valid integer value
and code
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('DELETE FROM Drogs WHERE Hraz = "0"');
SQLQuery1.ExecSQL;
"sometimes" gives error message
Database is locked
Any idea, why this happens? I'm out of options...
SQLQuery1.SQL.Add('VALUES('+sKod+','+sNaz+','+sHraz+')');
- bad code. Better use parameters and specify correct types for those parameters. bobby-tables.com/delphi.html – Arioch 'The