Board index » delphi » Store file in MEMO field

Store file in MEMO field

How do I store the contents of a file into a memo field. I cannot find
any examples. Could someone show me an example?

Thanks in advance,

 

Re:Store file in MEMO field


Quote
>How do I store the contents of a file into a memo field. I cannot find
>any examples. Could someone show me an example?

Try this

procedure TForm1.appendString(aMemoField , aStringField : Tfield );
/// This procedure appends a String field to aMemoField
begin
  with TMemo.create(self) do  // Instantiate a TMemo object
  try
    visible:= false;        
    parent := self;        
    aMemoField.dataSet.edit;  // Make sure the table is in edit mode
    lines.assign((aMemoField as TmemoField) ); //Copy the memo to TMemo  
    lines.add(aStringFld.asString);       //Add String filed              
    (aMemoField as TmemoField).assign(lines); // Copy the back to Memo field }
  finally
    free;  //If you create it free it    
  end;
end;
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Store file in MEMO field


Hi,

First load a memo with the file:

  Memo1.Lines.LoadFromFile('c:\files\file1.txt');

Then use the TBlobField.Assign method to copy Memo1 to your memo field.

Specify the Lines property of the TMemo as the parameter for the Assign
method.
  (where 'Notes' is a Memo field of Table1)

  Table1Notes.Assign(Memo1.Lines);

Or, if you do not use persistent field objects:

  TBlobField(Table1.FieldByName('Notes')).Assign(Memo1.Lines);

I hope it helps you.

Frank
--------------------

Quote
Norman McIntosh wrote:

> How do I store the contents of a file into a memo field. I cannot find
> any examples. Could someone show me an example?

> Thanks in advance,

Other Threads