Help! Saving TMemo data to Memo field of Database table 
Author Message
 Help! Saving TMemo data to Memo field of Database table

Does anybody know of an easy way to copy the contents of a TMemo
component into a Memo field of a Paradox table?

It seems like it should be really easy but I can't find out how in any
of the help files or delphi manuals...

Thanks in advance...
--
========================================================

Custom Components: TMovingButton and ScrollingBackground
 Available for free at -=>   http://www.*-*-*.com/
   Plus Delphi FAQ, some humor, sample apps and more!
========================================================



Sun, 30 May 1999 03:00:00 GMT  
 Help! Saving TMemo data to Memo field of Database table

Quote:
> Does anybody know of an easy way to copy the contents of a TMemo
> component into a Memo field of a Paradox table?

> It seems like it should be really easy but I can't find out how in any
> of the help files or Delphi manuals...

> Thanks in advance...
> --
> ========================================================

> Custom Components: TMovingButton and ScrollingBackground
>  Available for free at -=>  http://www.vcnet.com/mantis
>    Plus Delphi FAQ, some humor, sample apps and more!
> ========================================================

Here is a recent post addressing that topic in these forums from
Steve Koterski, (Borland International)

<Start Quote>

There are no memory variable types that correspond to a memo field, thus
there are no As* properties to go with the TMemoField component. To
programmatically write data to or read data from a memo field, you will
need to make use of a stream object. Delphi provides the TBlobStream object
for just this purpose.

The TBlobStream object includes a Write method (for writing data from a
PChar or equivalent for a memo field), a Read method (for reading data from
a memo field to a PChar), and a Create method (to create the object and, in
the process, connect it to the memo field in the current record in the
table). It also includes a Size property for determining the size in bytes
of the contents of the memo field for the current record.

Below is an example of using a TBlobStream object to write a string to a
memo field (in this example, named TEXT):

 procedure TForm1.Button1Click(Sender: TObject);
  var
    BS: TBlobStream;
    P: PChar;
    S: String;
  begin
    S := 'Here is the string to add to the memo';
    GetMem(P, Length(S));
    StrPCopy(P, S);
    try
      if not (Table1.State in [dsEdit, dsInsert]) then
        Table1.Edit;
      BS := TBlobStream.Create(TMemoField(Table1.FieldByName('TEXT')),
        bmWrite);
      BS.Write(P^, Length(S));
    finally
      BS.Free;
      FreeMem(P, Length(S));
    end;
  end;

<End Quote>

Hope that is what you need!

----
RKR

****************************************

****************************************



Sun, 30 May 1999 03:00:00 GMT  
 Help! Saving TMemo data to Memo field of Database table

Quote:

> > Does anybody know of an easy way to copy the contents of a TMemo
> > component into a Memo field of a Paradox table?

> > It seems like it should be really easy but I can't find out how in any
> > of the help files or Delphi manuals...

> > Thanks in advance...
> > --
> > ========================================================

> > Custom Components: TMovingButton and ScrollingBackground
> >  Available for free at -=>  http://www.vcnet.com/mantis
> >    Plus Delphi FAQ, some humor, sample apps and more!
> > ========================================================

> Here is a recent post addressing that topic in these forums from
> Steve Koterski, (Borland International)

> <Start Quote>

> There are no memory variable types that correspond to a memo field, thus
> there are no As* properties to go with the TMemoField component. To
> programmatically write data to or read data from a memo field, you will
> need to make use of a stream object. Delphi provides the TBlobStream object
> for just this purpose.

> The TBlobStream object includes a Write method (for writing data from a
> PChar or equivalent for a memo field), a Read method (for reading data from
> a memo field to a PChar), and a Create method (to create the object and, in
> the process, connect it to the memo field in the current record in the
> table). It also includes a Size property for determining the size in bytes
> of the contents of the memo field for the current record.

> Below is an example of using a TBlobStream object to write a string to a
> memo field (in this example, named TEXT):

>  procedure TForm1.Button1Click(Sender: TObject);
>   var
>     BS: TBlobStream;
>     P: PChar;
>     S: String;
>   begin
>     S := 'Here is the string to add to the memo';
>     GetMem(P, Length(S));
>     StrPCopy(P, S);
>     try
>       if not (Table1.State in [dsEdit, dsInsert]) then
>         Table1.Edit;
>       BS := TBlobStream.Create(TMemoField(Table1.FieldByName('TEXT')),
>         bmWrite);
>       BS.Write(P^, Length(S));
>     finally
>       BS.Free;
>       FreeMem(P, Length(S));
>     end;
>   end;

> <End Quote>

> Hope that is what you need!

> ----
> RKR

> ****************************************

> ****************************************

In Delphi 2.0+, the TMemoField does have an asString property enabled.

Mike



Mon, 31 May 1999 03:00:00 GMT  
 Help! Saving TMemo data to Memo field of Database table


Quote:

> Does anybody know of an easy way to copy the contents of a TMemo
> component into a Memo field of a Paradox table?

> It seems like it should be really easy but I can't find out how in any
> of the help files or Delphi manuals...

> Thanks in advance...
> --
> ========================================================

> Custom Components: TMovingButton and ScrollingBackground
>  Available for free at -=>  http://www.vcnet.com/mantis
>    Plus Delphi FAQ, some humor, sample apps and more!
> ========================================================

Try this:

ParadoxMemoField.Assign(MemoField.Lines)



Tue, 01 Jun 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Saving TMemo field data to a Blob field (Interbase Table) via SQL Update Query

2. Getting a Memo field in a table into a TMemo component

3. Need help accessing Paradox memo fields as TMemos

4. ask: Oracle Memo fields and Delphi TMemo component

5. Help: copy memo field from one table to another field

6. What about saving a Tmemo.lines in a memo field database ?

7. Copy data from string field to memo field

8. What is the syntax for copy a memo to a database memo field

9. TMemo fields, get/set data.

10. Save Memo-Field with SQL

11. Help:Saving Graphic Image Into A BLOB Graphic Field In Paradox Table

12. Help with Memo Field in Table

 

 
Powered by phpBB® Forum Software