[SOLVED] I ask for help for Sqlite DELETE not working lazarus / 16-Databases ---------------------------------------------------------------------- PDV · 2023-10-19 16:21 Hi everyone, I'm trying to build a small skeleton of a working program to access Sqlite, which I see is a problem for many, creating a Table works, inserting data works, I also managed to make the Update work but in a different way which I don't understand (is it possible to do it without first performing a Select?), but with Delete I'm stuck. I searched the forum and Google for a long time, tried and tried and now I'm stuck, so I ask for your help. I insert all the program code here, so you can easily see it and run it and modify it in such a way as to make it functional, and by doing so a small working software remains available to everyone who needs it, and everyone can learn without going crazy or having to give up. . I don't want to use DBgrids etc. because I prefer to process data with listboxes etc. and do it all via code. Nothing is set in the 3 components (SQLQuery, SQLite3Connection, SQLTransaction) I thank you if you can help me, then the code can grow and be useful to everyone, but a small working base is needed. Greetings from Italy (now it's raining and cold) ---------------------------------------------------------------------- PDV · 2023-10-19 19:42 Tonight I'm lucky, I managed to get everything to work, now see the Delete3 button. Post the working code. If you have comments or other ideas, I thank you. I will explore the various implementations and post the working code. I'm from BASIC, years ago I used Realstudio (now called Xojo). I had a 2012 version, 32 bit, now having problems with the computer I had to take it to another computer but the software house no longer offers automatic online authentication to obtain the authorization string, the message 'Call to this number in Italy'. I did and got no response. Then from the number I found out who it was assigned to, and I discovered that they had moved to another city, so I called them but I was told that they no longer collaborate with Xojo. I gave up, thinking of all the future problems...!!! Better Lazarrus which I can install on as many computers as I want. Years ago I had already tried with Lazarus but had given up due to the problem of accessing Sqlite, but I tried again, and now I have apparently succeeded. Coming from BASIC it's not nice to use PASCAL, but I'm getting used to it, and you feel that in Lazarus there is a much much powerful engine. Greetings everyone. ---------------------------------------------------------------------- Handoko · 2023-10-20 03:20 Hello PDV, Welcome to the forum. I quickly tested your code, it worked on Linux too. Below is the screenshot running the code on Ubuntu mate 23.04. I was a fan of BASIC, but it was too slow in the DOS era. Luckily I found Pascal, which was much faster and powerful. Pascal syntax can be a bit challenging for BASIC users. BASIC is good for simple projects but because Pascal 'force' users to do planning before coding and its verbosity, for medium and large projects Pascal codes are easier to maintenance. Currently I am learning Firebird. SQLite is okay but it is not suitable for multi-client environments. Maybe you should try Firebird. If you can use Firebird you should have no problem using SQLite, they have very similar SQL syntax. And if you're new in Lazarus you may interested to try these short demos: https://wiki.freepascal.org/Portal:HowTo_Demos ---------------------------------------------------------------------- PDV · 2023-10-27 19:14 I discovered that using the code found under the UPDATE button there is a problem: if you have previously deleted a record, for example record 2, a new record will be created with the empty ID field (= Null) and the NAME field as assigned . Try, you will continue to create new records, and this is a serious problem. I tried to create a new code (UPDATE2) with AConnection.ExecuteDirect, it behaves correctly, if the ID field = 2, previously deleted, no longer exists, it does not create any new records!! Post the new complete project with the two UPDATE variants. My problem in using Lazarus was just getting SqLite to work, now I've succeeded, and I post these things to help those like me who have problems with the first approach. Lazarus is phenomenal, I don't regret Realbasic (now Xojo) at all. Note that I removed the 3 visual components from the project, doing everything via code they are not necessary. Thank you all. ---------------------------------------------------------------------- PDV · 2023-10-28 14:00 UPDATED with Record Count working and another INSERT button to have more records ---------------------------------------------------------------------- PDV · 2023-10-28 21:22 UPDATED with Empty table and Vacuum ---------------------------------------------------------------------- PDV · 2023-11-02 20:51 UPDATED Inserted a check to see if a record actually exists, and a check to see if the database file exists. Read previous posts. I used the code to make Sqlite work in an application I'm writing, everything works fine with no problems. I needed Sqlite for an application with only a local database, without Dbgrid and similar stuff, all done via code without visual components. ---------------------------------------------------------------------- PDV · 2023-11-03 23:19 UPDATE: working with dates