Board index » delphi » storing text in a memo field

storing text in a memo field

I can I store data into a memo field?  I have it set up in the table as
type memo with a length of 1.  I'm trying to store text into it from
multiple text boxes, but it seems to clip it.  Here is what I'm doing,
for example:

        dtmData.CurrentTable.FieldByName('CardText').Value :=
          Edit1.Text + #13#10 + Edit2.Text + #13#10 + Edit3.Text +
          #13#10 + Edit4.Text + #13#10 + Edit5.Text;

What seems to be happening is it's only taking the first 240 (or
thereabouts) characters and storing them, the rest is getting truncated,
and not stored.  How do I go about storing the strings of text to insure
they all get saved to the table?

Thanks!

- Scott Bukoski

 

Re:storing text in a memo field


On Thu, 17 Jun 1999 14:00:35 -0400, Scott Bukoski <sbuko...@ttsoa.com>
wrote:

Quote
>I can I store data into a memo field?  I have it set up in the table as
>type memo with a length of 1.  I'm trying to store text into it from
>multiple text boxes, but it seems to clip it.  Here is what I'm doing,
>for example:

>    dtmData.CurrentTable.FieldByName('CardText').Value :=
>      Edit1.Text + #13#10 + Edit2.Text + #13#10 + Edit3.Text +
>      #13#10 + Edit4.Text + #13#10 + Edit5.Text;

>What seems to be happening is it's only taking the first 240 (or
>thereabouts) characters and storing them, the rest is getting truncated,
>and not stored.  How do I go about storing the strings of text to insure
>they all get saved to the table?

What version of Delphi are you using? Are you sure only 240 characters are
being stored and not 254? What type of table was used?

Here is the test routine that worked for me (latest Delphi & BDE, level 7
Paradox table with Memo field).

  procedure TForm1.Button1Click(Sender: TObject);
  const
    CRLF = #13 + #10;
  var
    a, b, c, d, e, f: String;
  begin
    a := 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
    b := 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
    c := 'cccccccccccccccccccccccccccccccccccccccccccccccccc';
    d := 'dddddddddddddddddddddddddddddddddddddddddddddddddd';
    e := 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
    f := 'ffffffffffffffffffffffffffffffffffffffffffffffffff';
    with Table1 do begin
      if not (State in [dsInsert, dsEdit]) then Insert;
      FieldByName('Text').Value := a + CRLF +
        b + CRLF +
        c + CRLF +
        d + CRLF +
        e + CRLF +
        f;
      Post;
      Caption := 'Number of characters written to memo: ' +
        IntToStr(Length(FieldByName('Text').Value));
    end;
  end;

This successfully stores 310 characters to the Memo field (300 alpha
characters, five carriage-return characters, and five line-feed
characters).

//////////////////////////////////////////////////////////////////////////
Steve Koterski                    "My problem lies in reconciling my gross
Technical Publications            habits with my net income."
INPRISE Corporation                             -- Errol Flynn (1909-1959)
http://www.borland.com/delphi

Re:storing text in a memo field


Quote
In article <376937C3.54FEF...@ttsoa.com>, Scott Bukoski wrote:
> How do I go about storing the strings of text to insure
> they all get saved to the table?

The easiest way is to transfer the data via a temporary stringlist:

  var lst: TStringList;

  lst := TStringList.Create;
  try
    lst.Add(Edit1.Text);
    ..
    lst.Add(Edit5.Text);
    dtmData.CurrentTable.FieldByName('CardText').Assign(lst);
  finally
    lst.Free;
  end;

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03)
 (Unsolicited e-mail replies will most likely be ignored)

Other Threads