Recent

Author Topic: Lazarus 4.2 sqlite3 db  (Read 4704 times)

Brownfox

  • Newbie
  • Posts: 1
Re: Lazarus 4.2 sqlite3 db
« Reply #15 on: August 30, 2025, 09:24:14 am »
Thank you all, I am going to follow your advice, best regards.

egsuh

  • Hero Member
  • *****
  • Posts: 1696
Re: Lazarus 4.2 sqlite3 db
« Reply #16 on: September 02, 2025, 08:53:48 am »
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

  • Hero Member
  • *****
  • Posts: 6886
Re: Lazarus 4.2 sqlite3 db
« Reply #17 on: September 02, 2025, 10:28:48 am »
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);     ?
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

  • Full Member
  • ***
  • Posts: 169
Re: Lazarus 4.2 sqlite3 db
« Reply #18 on: September 02, 2025, 11:22:35 am »
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.
Lazarus stable, Win32/64

 

TinyPortal © 2005-2018