* * *

Author Topic: [SOLVED] Why is DBMemo hanging up after ApplyUpdates?  (Read 847 times)

Landslyde

  • Full Member
  • ***
  • Posts: 163
[SOLVED] Why is DBMemo hanging up after ApplyUpdates?
« on: July 01, 2018, 05:52:41 am »
When I double-click the DBMemo to edit, it hangs up and won't do anything until I click back into it again. The behavior's strange.

Here are the project files. Run it and click the cupcake (seriously :D), then doubleclick the DBMemo on far right. Whether you cancel the edit or update it, it still locks up. And I can't figure out why that's happening. A little insight here wld be appreciated.

The code in recipe_name_grid.pas that opens the edit:
Code: Pascal  [Select]
  1. procedure TRecipes.DBMemo1DblClick(Sender: TObject);
  2. var
  3.   Frm : Tfrm_edit_memo;
  4. begin
  5.   Frm := Tfrm_edit_memo.Create(Nil);
  6.   try
  7.      Frm.fID := Query3.FieldByName('name_id').AsInteger;
  8.      Frm.ShowModal;
  9.    finally
  10.      Frm.Free;
  11.      Query3.ApplyUpdates;
  12.      Query1.Refresh; // initially used Query3 here. Then tried Query2. Just trying with zero success.
  13.    end;
  14. end;

and the edit_memo.pas code:
Code: Pascal  [Select]
  1. procedure Tfrm_edit_memo.btnUpdateClick(Sender: TObject);
  2. begin
  3.   SQLQuery1.SQL.Text:='UPDATE recipe_notes SET note = :note WHERE name_id = :id';
  4.   SQLQuery1.ParamByName('note').AsString:=DBMemo1.Text;
  5.   SQLQuery1.ParamByName('id').AsInteger:=fID;
  6.   SQLQuery1.ExecSQL;
  7.   DataMod.SQLTransaction1.CommitRetaining;
  8.   SQLQuery1.Active:=False;  // recently added with no affect
  9.   Close;
  10. end;

Thanks
« Last Edit: July 02, 2018, 11:08:49 pm by Landslyde »
Linux Mint 19
Lazarus 1.8.4
FPC 3.0.4

mangakissa

  • Hero Member
  • *****
  • Posts: 830
Re: Why is DBMemo hanging up after ApplyUpdates?
« Reply #1 on: July 02, 2018, 08:51:36 am »
Why are you using a DBMemo if you writing the text directly to your table?
DBMemo is connected to your dataset, so any changes (when DBMemo is modified) are saved to your tabel when you call 'post'.
In other case don't use DBMemo but memo.
Why are you creating a DBMemo at runtime when you have a form at desingtime?
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

Landslyde

  • Full Member
  • ***
  • Posts: 163
Re: Why is DBMemo hanging up after ApplyUpdates?
« Reply #2 on: July 02, 2018, 05:34:30 pm »
Why are you using a DBMemo if you writing the text directly to your table?
For the same reason you're using DBAware components on your FrmAuthorEdit in your sqldb project. I'm just mimicking what you did.

Quote from: mangakissa
DBMemo is connected to your dataset, so any changes (when DBMemo is modified) are saved to your tabel when you call 'post'.
In other case don't use DBMemo but memo.
Noted.

Quote from: mangakissa
Why are you creating a DBMemo at runtime when you have a form at desingtime?
Yeah, I'm really lost on all of this. Thing is, I was copying you. But it seems I did a few things you didn't do. I mean, you created forms at runtime, forms you had completed at design time. But I guess I did something wrong there. Please refer to sqldb project you sent me to understand why I did this.

Some people are better with this than others. Like you, mangakissa...you're better at it than I am. That doesn't mean I'm not trying. I'm just not grasping some things as well as you. Anyway, thank you for your help.
« Last Edit: July 02, 2018, 11:08:02 pm by Landslyde »
Linux Mint 19
Lazarus 1.8.4
FPC 3.0.4

mangakissa

  • Hero Member
  • *****
  • Posts: 830
Re: [SOLVED] Why is DBMemo hanging up after ApplyUpdates?
« Reply #3 on: July 03, 2018, 08:57:50 am »
Quote
Some people are better with this than others. Like you, mangakissa...you're better at it than I am. That doesn't mean I'm not trying. I'm just not grasping some things as well as you. Anyway, thank you for your help.
I'm just an average  developer with a lot of years working with Pascal OOP progamming.
I'm glad that you try it yourself and we on this forum are helping you as much as we can.

As you already said my forms are loaded @rumtime which already designed. As you also can see that the form is not connected the the table of the previous form. It has his own connection to a dataset.
That's why it can work independent.

In your case (when you want to start a memo for the description) my above answer is the quickiest way.

You don't want to see my first program written in Delphi :D
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

Landslyde

  • Full Member
  • ***
  • Posts: 163
Re: [SOLVED] Why is DBMemo hanging up after ApplyUpdates?
« Reply #4 on: July 03, 2018, 01:17:53 pm »
Thanks, mangakissa. I followed what you said and fixed it right away.
Linux Mint 19
Lazarus 1.8.4
FPC 3.0.4

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus