Recent

Author Topic: [SOLVED] how to refresh data in TDBMemo?  (Read 7046 times)

eara

  • Jr. Member
  • **
  • Posts: 84
[SOLVED] how to refresh data in TDBMemo?
« on: April 15, 2014, 12:46:18 pm »
i have a db form with a TDBMemo control e.g. edt_authors
the control  is bound to a db text field and want to keep small in size so i designed it like the other TDBEdit fields in my form, to occupy a single line.

Now in case the user want to put there a large amount of authors, i have a seperate form for editing text fields, lets say dlgTextFieldEditor which holds a big TDBMemo, lets say edt_big_memo.

When user calls this form, i set
edt_big_memo.Datasource:=edt_authors.Datasource
edt_big_memo.DataField:=edt_authors.DataField
and show form as modal.

When user is finished with editing and closes the form with the edt_big_memo
the edt_authors is not updated, but the underlying field it is.

This is my problem, how to update the edt_authors to reflect the changes, without posting the record ?
« Last Edit: April 19, 2014, 09:16:12 pm by eara »

JanRoza

  • Hero Member
  • *****
  • Posts: 591
    • http://www.silentwings.nl
Re: how to refresh data in TDBMemo?
« Reply #1 on: April 15, 2014, 01:07:50 pm »
Have you tried edt_big_memo.refresh?
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Laz: Lazarus 2.0.10 FPC 3.2.0
       CodeTyphon 7.2 FPC 3.3.1

eara

  • Jr. Member
  • **
  • Posts: 84
Re: how to refresh data in TDBMemo?
« Reply #2 on: April 15, 2014, 01:28:39 pm »
i think i have.
I change course now and i try with TMemo editor ...

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: how to refresh data in TDBMemo?
« Reply #3 on: April 15, 2014, 10:56:08 pm »
Maybe I am missing the point: What's wrong with posting the data?

As long as you don't do any ApplyUpdates, the data won't be in your database...

(assuming you're using an access layer like SqlDB)
Lazarus 2.0.4/FPC 3.0.4/Win 64

eara

  • Jr. Member
  • **
  • Posts: 84
Re: how to refresh data in TDBMemo?
« Reply #4 on: April 16, 2014, 12:48:16 am »
the point was that user sees in a db form an edit box with lots of data and he presses the button next to it which opens a seperate big editor window, and do his changes there. Finally he presses the ok button and looks back to the edit box which still has the old value, but the bound TField has the changes which user can't see.

Anyway, solution was simple i replaced TDBMemo in dlgTextField dialog with TMemo, and i copy value from edit control to edit control without Tfield interfearance.

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: how to refresh data in TDBMemo?
« Reply #5 on: April 17, 2014, 06:04:39 pm »
Wouldn't a simple table/query refresh have done this?
Lazarus 2.0.4/FPC 3.0.4/Win 64

eara

  • Jr. Member
  • **
  • Posts: 84
Re: how to refresh data in TDBMemo?
« Reply #6 on: April 18, 2014, 02:04:07 am »
Wouldn't a simple table/query refresh have done this?
plz read my scenario, i am in the middle of an EDIT operation so refresh what ? it is something that has to do with TEXT fields that are handled like BLOBS, so mayby for optimization reasons (i don't know really, i just suspect) underlying TField is not immediatly updated from TDBMemo control until changes going to db.
I fall again in a similar case in event OnBeforePost where i want to validate or manipulate data in an TDBMemo control which is bound to a TEXT Field in MySQL (that means looooooong text), and i avoid to use the value from FieldByName cause is not returning all the data from the TDBMemo, instead i use the TDBMemo.Text...

anyway don't bother more with that... as i mention before solution is simpler: i used a TMemo and i copy text from control to control (instead from control to field)

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: how to refresh data in TDBMemo?
« Reply #7 on: April 18, 2014, 06:20:48 am »
first and most important please create a small demo showing that problem. The rest follows.

Wouldn't a simple table/query refresh have done this?
plz read my scenario, i am in the middle of an EDIT operation so refresh what ? it is something that has to do with TEXT fields that are handled like BLOBS, so mayby for optimization reasons (i don't know really, i just suspect) underlying TField is not immediatly updated from TDBMemo control until changes going to db.
No a dataset is a client side cursor and it should behave like one, when data are changed from one component it automatically reflectst the changes to all the components that show those data. Data change includes but is not limited to scrolling the dataset changing the datasets state and of course changing the data of a single field on the active record. Any of the above operations should change the visual data on all linked components.
I fall again in a similar case in event OnBeforePost where i want to validate or manipulate data in an TDBMemo control which is bound to a TEXT Field in MySQL (that means looooooong text), and i avoid to use the value from FieldByName cause is not returning all the data from the TDBMemo, instead i use the TDBMemo.Text...
da! FieldByname returns the tfield in client side that holds the data to be used. If you do MyDatasets.FieldByname('Myfield').Value should return all the data if it is not then please provide with a demo to look at what you describe is not possible as far as I know.

anyway don't bother more with that... as i mention before solution is simpler: i used a TMemo and i copy text from control to control (instead from control to field)

Yeah that is a work around not a solution and it is something you do to avoid problems with the underline component suite again a demo would be required at this point what you describe it should never happen and if does happens then there are bugs that need to be reported.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

eara

  • Jr. Member
  • **
  • Posts: 84
Re: how to refresh data in TDBMemo?
« Reply #8 on: April 19, 2014, 01:30:16 am »
Quote
Yeah that is a work around not a solution and it is something you do to avoid problems with the underline component suite again a demo would be required at this point what you describe it should never happen and if does happens then there are bugs that need to be reported
:o

well ...  it is a solution, as long as it solves problems, and the biggest problem of all is .... TIME!
I made a test program that reproduces what i did. Mayby i made things wrong, mayby not, i don't know, take a look if you want...
« Last Edit: April 19, 2014, 01:35:10 am by eara »

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: how to refresh data in TDBMemo?
« Reply #9 on: April 19, 2014, 02:25:29 am »
thank you I will after the holidays.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: how to refresh data in TDBMemo?
« Reply #10 on: April 19, 2014, 08:10:53 pm »
procedure TForm1.returnClick(Sender: TObject);
begin
  GroupBox1.Enabled:=True;
  GroupBox2.Enabled:=False;
  DBMemo2.EditingDone;
  DBMemo2.ReadOnly:=true;
  //
  DBMemo1.Text :=  DBMemo2.Text;
  DBMemo1.Refresh;
  DBMemo2.DataSource:=nil;
  DBMemo2.DataField:='';
end;
Lazarus 2.0.4/FPC 3.0.4/Win 64

eara

  • Jr. Member
  • **
  • Posts: 84
Re: how to refresh data in TDBMemo?
« Reply #11 on: April 19, 2014, 09:11:41 pm »
merci for your time...
I got the point... 

DBMemoX.Text:=DBMemoY.Text

actually this is what i doing now with Memo : Memo.Text := DBMemo.Text

 

TinyPortal © 2005-2018