• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Assigning data to a database memo field

An easy one for you (probably)!

When appending data from a screen form to a database I'm using syntax like

FieldByName('CallType').AsString := edtCallType.Text;

What's the corresponding syntax for a memo field?

I assumed it would be something like

FieldByName('Comments').AsMemo := mmComments.Lines;

but life isn't that simple...

Many thanks for your help
0
riccohb
Asked:
riccohb
  • 3
1 Solution
 
kretzschmarCommented:
just from head,
don't know if possible

TBlobField(FieldByName('Comments')).Text := mmComments.Lines;

or

TBlobField(FieldByName('Comments')).asText := mmComments.Lines;

or also

TBlobField(FieldByName('Comments')).asString := mmComments.Lines;

meikl ;-)
0
 
riccohbAuthor Commented:
Thanks for your help, but...

TBlobField(FieldByName('Comments')).Text := mmComments.Lines;

and

TBlobField(FieldByName('Comments')).asString := mmComments.Lines;

bring up the error 'Incompatible types: String and TStrings'

There's no such identifier as 'asText'.
0
 
kretzschmarCommented:
use
mmComments.text;

0
 
kretzschmarCommented:
if all fails

var
  m : tmemorystream;
begin
  m := tmemorystream.Create;
  try
    mmComments.Lines.SaveToStream(m);
    m.position := 0;
    TBlobField(FieldByName('Comments')).LoadFromStream(m);
  finally
    m.free;
  end;
end;

meikl ;-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now