Board index » delphi » Problem inserting (text) blob field into database

Problem inserting (text) blob field into database

I am tring to insert memo text into a memo field in an Access
Database through ODBC.

The following code snippet does not work.

With table1 do
  Begin
    Last;
    insert;
    FieldbyName('Memo_Comments').AsString := Memo1.Text;
    Post;
  End;

Memo1 is a Memo component while the field is a blob field or Access
memo field.

I get the same problem with Paradox so I have ruled out the ODBC issue.
I get an error message stating "Cannot access Field 'Memo_Comments'
as type string".

I have looked for code on pushing Blob fields into a database with
no luck. I have tried the "As" converson function without luck too. Any
help or snippets would be greatly appreciated.

Steve Plotkin
Tierra Software Systems

 

Re:Problem inserting (text) blob field into database


In article <4km367...@news.icanect.net>, tie...@icanect.net (Steven Plotkin)
wrote:

Quote
>I am tring to insert memo text into a memo field in an Access
>Database through ODBC.

>The following code snippet does not work.

>With table1 do
>  Begin
>    Last;
>    insert;
>    FieldbyName('Memo_Comments').AsString := Memo1.Text;
>    Post;
>  End;

>Memo1 is a Memo component while the field is a blob field or Access
>memo field.

>I get the same problem with Paradox so I have ruled out the ODBC issue.
>I get an error message stating "Cannot access Field 'Memo_Comments'
>as type string".

>I have looked for code on pushing Blob fields into a database with
>no luck. I have tried the "As" converson function without luck too. Any
>help or snippets would be greatly appreciated.

Haven't looked it up, but I do believe this'll work.

TMemoField(FieldByName('Memo_Comment')).Assign(Memo1.Lines)

This line typecasts the TField to a TMemoField and uses the Assign method to
read all lines from Memo1. If this don't work, mail me, and i'll look up how I
did it.

Erik Sperling Johansen
e...@interlink.no

Other Threads