Lazarus 4.2 sqlite3 db lazarus / 16-Databases ---------------------------------------------------------------------- Brownfox · 2025-08-22 12:28 Hi, I am a beginner and I am trying to build a very simple daat base for my club. I want display a field in a DBmemo, I have added a DBmemo, set datasouce and data field and add this line in procedure add : SQLQuery.Params.ParamByName('Cotis').AsString := DBMemo1.Lines.Text; I don't get compiler error but it doesn't work so I need some help. I apologize for my bad English. Thanks and Salutations Bernard. ---------------------------------------------------------------------- BlueIcaro · 2025-08-22 18:42 Hello, You don't give us a lot off information. Please show your code. Also If you are starting with DataBase in Lazarus you can check the wiki: https://wiki.freepascal.org/SQLdb_Tutorial1 /BlueIcaro ---------------------------------------------------------------------- Brownfox · 2025-08-26 09:47 Hi, Thanks for your reply. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i       // Requête INSERT      SQLQuery.SQL.Text := 'INSERT INTO adherents (Nom, Prenom,Mail,Adresse,Tel, Date,Cotis) VALUES (:Nom, :Prenom,:Mail, :Adresse, :Tel, :Date,:Cotis)';      SQLQuery.Params.ParamByName('Nom').AsString     := EditNom.Text;      SQLQuery.Params.ParamByName('Prenom').AsString  := EditPrenom.Text;    SQLQuery.Params.ParamByName('Mail').AsString    := EditMail.Text;    SQLQuery.Params.ParamByName('Adresse').AsString := EditAdresse.Text;      SQLQuery.Params.ParamByName('Tel').AsString   := EditTel.Text;      SQLQuery.Params.ParamByName('Cotis').AsString := AnsiString(DBMemo1.Lines.Text); In the sqlite3  table, the field cotis is set as text. DBMemo1 datasource and datafield are set + r/w ok The first 5 lines are ok in DBGrid What is wrong in this line : SQLQuery.Params.ParamByName('Cotis').AsString := AnsiString(DBMemo1.Lines.Text);     ? Merci ---------------------------------------------------------------------- Zvoni · 2025-08-26 10:31 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SQLQuery.Params.ParamByName('Cotis').AsString := AnsiString(DBMemo1.Lines.Text);//Change toSQLQuery.Params.ParamByName('Cotis').AsMemo := DBMemo1.Lines.Text; ---------------------------------------------------------------------- Brownfox · 2025-08-26 11:27 Thank you, but that doesn't work. ---------------------------------------------------------------------- paweld · 2025-08-26 13:03 This is because TDBMemo does not contain any data - it is only a link to a field in the database. So either use TMemo: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SQLQuery.Params.ParamByName('Cotis').AsMemo := Memo1.Lines.Text;or retrieve the relevant data and DBMemo: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SQLQuery.Params.ParamByName('Cotis').AsMemo := DBMemo1.Field.Text; ---------------------------------------------------------------------- Brownfox · 2025-08-26 18:20 Hi, thanks for your reply. When I add a member I fill DBMemo, it is not empty. In order to debug, I added an Tedit and a button: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  Edit1.Text := DBMemo1.Lines.Text;end;                  And edit1 contains what I wrote in DBMemo. I wonder why DBMemo is not in the table field. May be because i create the table with a python script ?????, I'm lost ---------------------------------------------------------------------- cdbc · 2025-08-26 19:41 Hi Attached is a small Sqlite3-Demo-App, you can have a look at... It amo. deals with memo-text... Regards Benny ---------------------------------------------------------------------- CharlyTango · 2025-08-26 22:29 @cdbc cannot compile the demo with fixes/fixes 4.3 istrlist.pas(39,41) Error: Cannot find sortbase used by istrlist. BTW: you give a beginner a MVC Solution as a Demo ? ---------------------------------------------------------------------- cdbc · 2025-08-26 23:03 Hi To compile in fpc fixes you have to change this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifNdef VER3_2_2}to this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$if fpc_fullversion > 30204}The 'istrlist' was implemented before fpc fixes was thought of and I wasn't aware that it wouldn't compile -- sorry mate. In all fairness, it's /not/ the full-blown MVC, just a sane separation of concerns -- MV If you like -- ...and why shouldn't a newbie learn the good practices from the 'GetGo'?!?  Regards Benny ---------------------------------------------------------------------- CharlyTango · 2025-08-26 23:03 @Brownfox: Yes there are different and more sophisticated methods to create a database application. All of them have their justification and purpose, depending on the size of the project, its use, and the programmer's experience. You described yourself as a beginner, so I'll show you how to solve your problem using Lazarus's built-in tools. You don't have to deal with parameters at all, because Lazarus's database components do that for you. In the small test application, you will see a simple mask in the fcustomer.pas form. The form only contains a grid, several data-sensitive input fields, and a DBNavigator that takes control. The database components determine how to handle the assigned SQL statement. Of course, you can make everything more beautiful and complex, but this should be enough for a first understanding. ---------------------------------------------------------------------- CharlyTango · 2025-08-26 23:13 Quote from: cdbc on August 27, 2025, 01:03:19 am...and why shouldn't a newbie learn the good practices from the 'GetGo'?!?  Because maybe he should walk first, then run, and only later jump and fly. I agree with you that some things aren't ideal (although MVC is pretty awesome). But if I had been presented with something like that when I was starting out, I would have run away screaming. I can talk about an theme that I really understand. Let's just say that it's probably not very wise from a teaching perspective to confront a talented beginner dancer with highly complex movements. ---------------------------------------------------------------------- cdbc · 2025-08-26 23:23 Hi Okidoki, duly noted, but WTH, maybe someday he'll appreciate it  Regards Benny ---------------------------------------------------------------------- CharlyTango · 2025-08-27 06:21 After taking a closer look, I can say with certainty that he will appreciate it—maybe in a year or two. But there are some things that even an old dog like me can learn, while others I don't understand strategically, but you'll have your reasons. ---------------------------------------------------------------------- Jurassic Pork · 2025-08-27 23:06 Hello, you can have a look to my sqlite3 Database example project in the examples of Lazarus ( examples/database/image_mushrooms). In the Gui you have a TDbMemo (Notes) And in the code you can recreate the structure of the sqlite 3 database from sql : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i       SQLite3Connection1.ExecuteDirect(      'CREATE TABLE DeadlyMushrooms '+LineEnding+      '-- This table created by Jurassic Pork '+LineEnding+      '-- for Free Pascal Lazarus '+LineEnding+      '-- Create date:2013-08-05 23:55:09 '+LineEnding+      '( '+LineEnding+    '       ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, '+LineEnding+      '       Scientific_Name VARCHAR NOT NULL, '+LineEnding+      '       Common_Name VARCHAR, '+LineEnding+      '     `Order`  VARCHAR, `Genus`  VARCHAR, `Notes`  TEXT, `Picture`  BLOB, `Image_Link`  VARCHAR)'      ); The example needs the packages lazreport, SQLDBLaz to be installed. Friendly, J.P ---------------------------------------------------------------------- Brownfox · 2025-08-30 07:24 Thank you all, I am going to follow your advice, best regards. ---------------------------------------------------------------------- egsuh · 2025-09-02 06:53 Other advisors are real experts, and I'd like to ask more basic question ^^ Is DBMemo TMemo or TDBMemo? Data-aware controls, like TDBMemo, TDBEdit, etc. are linked to dataset directly via TDataSource. I'm curious your structure. Anyway following always worked in my applications.    SQLQuery.ParamByName('Cotis').AsString := DBMemo1.Lines.Text; ---------------------------------------------------------------------- rvk · 2025-09-02 08:28 Quote from: Brownfox on August 26, 2025, 11:47:15 amIn the sqlite3  table, the field cotis is set as text. DBMemo1 datasource and datafield are set + r/w ok The first 5 lines are ok in DBGrid What is wrong in this line : SQLQuery.Params.ParamByName('Cotis').AsString := AnsiString(DBMemo1.Lines.Text);     ? Yeah. That's a big no-no. You are mixing DB-aware components with filling the insert manually. If the DBMemo is connected to the same SQLQuery then this could be a problem. Either just use a TMemo (not DB-aware) and use your .AsString line. Or convert completely to TDBMemo and TDBEdit components and remove all the .AsString lines. You can create an SQLQuery with select and (with internal insert and update queries) you can just use Edit and Insert on them without writing a single line of code. ---------------------------------------------------------------------- CharlyTango · 2025-09-02 09:22 Here you will find an example with data aware controls. Including a TDBMemo. In fcustomer.pas a grid, TDBMemo and data aware controls are clicked together with a TDBNavigator an that works without any coding. In this Example ei assigned the SQL statement in the code but even this is unecessary and can be done in the Lazarus GUI using the Object Inspector.