Board index » delphi » How to read/write memo from/to table?

How to read/write memo from/to table?

Hi,

Is there anyway to read memo for memo field in a  table to TMemo, so I can
make changes then write it back to table?

Thanks,

James

 

Re:How to read/write memo from/to table?


Read ...
Memo1.Text := Query1.FieldByName('Note').AsString;

and write ...
var
  p: PChar;
  s: Integer;
begin

blah blah blah ...

  s := Memo1.GetTextLen + 1;
  p:= AllocMem(s);
  try
     FillChar(p^, s, #0);
     Memo1.GetTextBuf(p, s);
     Query1.Params[0].AsMemo := p;
  finally
     FreeMem(p, s);
  end;

blah bla execute

Quote
"James Yang" <jamesyang...@yahoo.com> wrote in message

news:3b0eccfa_1@dnews...
Quote
> Hi,

> Is there anyway to read memo for memo field in a  table to TMemo, so I can
> make changes then write it back to table?

> Thanks,

> James

Re:How to read/write memo from/to table?


Quote
Dejan wrote in message <3b0eec8a_1@dnews>...
>Read ...
>Memo1.Text := Query1.FieldByName('Note').AsString;

>and write ...
>var
>  p: PChar;
>  s: Integer;
>begin

[snip complicated stuff]

You can write back the same way you read:

Query1.FieldByName('Note').AsString := Memo1.Text;
--
Wayne Niddery (WinWright Inc.)
RADBooks - http://www.logicfundamentals.com/RADBooks/delphibooks.html
"At the apex of every great tragedy of mankind there stands the figure
of an incorruptible altruist" - Ayn Rand

Re:How to read/write memo from/to table?


Hey there,

Try to use a "Blob" ("subtype 1" if you're using Interbase):
You cannot be sure, how much Text you'll get back in your field, so a Blob
is the best to manage very long Text...
Bye,
Lo?s.

"James Yang" <jamesyang...@yahoo.com> schrieb im Newsbeitrag
news:3b0eccfa_1@dnews...

Quote
> Hi,

> Is there anyway to read memo for memo field in a  table to TMemo, so I can
> make changes then write it back to table?

> Thanks,

> James

Re:How to read/write memo from/to table?


Thank you both for giving much simpler way to handle the memo field.  I used
much complicated way before.

James

"Wayne Niddery (TeamB)" <winwri...@chaffhome.com> wrote in message
news:3b0efc97$1_2@dnews...

Quote
> Dejan wrote in message <3b0eec8a_1@dnews>...
> >Read ...
> >Memo1.Text := Query1.FieldByName('Note').AsString;

> >and write ...
> >var
> >  p: PChar;
> >  s: Integer;
> >begin

> [snip complicated stuff]

> You can write back the same way you read:

> Query1.FieldByName('Note').AsString := Memo1.Text;

> --
> Wayne Niddery (WinWright Inc.)
> RADBooks - http://www.logicfundamentals.com/RADBooks/delphibooks.html
> "At the apex of every great tragedy of mankind there stands the figure
> of an incorruptible altruist" - Ayn Rand

Other Threads