Board index » delphi » Memo Fields in Access and Memo object in Delphi

Memo Fields in Access and Memo object in Delphi

Hi All;

I would like to use an insert query to populate an Access table containing a
memo field. I am assigning parameters in the sql statement but when I try:

params[0].astext := memo1.lines;

I get  "incompatable types 'String' and 'TString'". What is the proper
casting for the parameter? aslines?, asmemo? Simple answer I'm sure. I just
have very little experience using memo objects and databases. Thanks.

Richard McAuliffe

 

Re:Memo Fields in Access and Memo object in Delphi


Try something like..

params.assign(memo1.lines);

if not then make a tempsl

sl.assign(memo1)

will work, (going from memory, if you still have problems contact me via
email, and I will look at the old project that did that stuff...

HTH,
tom

Quote
Richard B. McAuliffe wrote in message <7sc90s$j...@forums.borland.com>...
>Hi All;

>I would like to use an insert query to populate an Access table containing
a
>memo field. I am assigning parameters in the sql statement but when I try:

>params[0].astext := memo1.lines;

>I get  "incompatable types 'String' and 'TString'". What is the proper
>casting for the parameter? aslines?, asmemo? Simple answer I'm sure. I just
>have very little experience using memo objects and databases. Thanks.

>Richard McAuliffe

Re:Memo Fields in Access and Memo object in Delphi


Thanks Tom. I couldn't get assign to work. Just want to insert contents of a
memo into an Access database which has a 'memo' datatype. Isn't there an
"as<something>" typecasting function for memos? Getting frustrated now.
Thanks anyway.

Richard

Quote
Tom <tguar...@ads-corp.com> wrote in message

news:7sdcrl$d5s8@forums.borland.com...
Quote
> Try something like..

> params.assign(memo1.lines);

> if not then make a tempsl

> sl.assign(memo1)

> will work, (going from memory, if you still have problems contact me via
> email, and I will look at the old project that did that stuff...

> HTH,
> tom

> Richard B. McAuliffe wrote in message <7sc90s$j...@forums.borland.com>...
> >Hi All;

> >I would like to use an insert query to populate an Access table
containing
> a
> >memo field. I am assigning parameters in the sql statement but when I
try:

> >params[0].astext := memo1.lines;

> >I get  "incompatable types 'String' and 'TString'". What is the proper
> >casting for the parameter? aslines?, asmemo? Simple answer I'm sure. I
just
> >have very little experience using memo objects and databases. Thanks.

> >Richard McAuliffe

Re:Memo Fields in Access and Memo object in Delphi


On Thu, 23 Sep 1999 22:20:55 -0400, "Richard B. McAuliffe"

Quote
<rbmcauli...@mail.toast.net> wrote:
>Thanks Tom. I couldn't get assign to work. Just want to insert contents of a
>memo into an Access database which has a 'memo' datatype. Isn't there an
>"as<something>" typecasting function for memos? Getting frustrated now.

Tested under Delphi 5, the following approach worked for me:

  Query1.ParamByName('DataParam').Assign(Memo1.Lines);

This also worked:

  Query1.ParamByName('DataParam').AsMemo := Memo1.Lines.Text;

As did this slight variation on the preceding example:

  Query1.ParamByName('DataParam').AsMemo := PChar(Memo1.Lines.Text);

Still another approach would be to create a TMemoryStream object. The
TStrings.SaveToStream method would copy from TMemo to stream and
TParam.LoadFromStream from memory stream to TParam.

==========================================================================
Steve Koterski                  "Computers are useless. They can only give
Technical Publications          you answers."
Borland                                       -- Pablo Picasso (1881-1973)
http://www.borland.com/techpubs/delphi

Other Threads