Board index » delphi » copy rows from table to typed file, problem with data from memo field

copy rows from table to typed file, problem with data from memo field

D3, BDE 5.01 and paradox 7.0

Idea: copy data from table to typed file

Problem: data from memo field missing      
=====================================

the code:
-------------------------
  .
  .
  .
      ordbogTabel.first.
      ordbogTabel.DisableControls;

      while NOT (ordbogTabel.eof) do
        begin
          NUR.gloseID          := ordbogTabel.Fields[0].AsInteger;
          NUR.titelID          := ordbogTabel.Fields[1].AsInteger;
          NUR.Fremmedsprog     := ordbogTabel.Fields[2].AsString;
          NUR.hovedsprog       := ordbogTabel.Fields[3].AsString;
          NUR.sek_betydning    := ordbogTabel.Fields[4].AsString;
          NUR.ordklasse        := ordbogTabel.Fields[5].AsString;
          NUR.koen             := ordbogTabel.Fields[6].AsString;
          NUR.kommentar        := ordbogTabel.Fields[7].AsString; //
memo field *)
          NUR.FremSample       := ordbogTabel.Fields[8].AsString;
          NUR.ModerSample      := ordbogTabel.Fields[9].AsString;
          write(NUF, NUR);
          ordbogTabel.Next;
        end;
        CloseFile(NUF);

        ordbogTabel.EnableControls;

  .
  .
  .
------------

      *) from the memo field only first 5 characters are copied to
NUR.kommentar, why?
         The memo field size is set to 240. How do I get more characters from
the memo field?

Regards,

Georg
gbc*design

 

Re:copy rows from table to typed file, problem with data from memo field


what is the declaration of the record ?
(what is kommentar type ?)

--
Olivier Dahan
oda...@{*word*104}cable.fr
Delphi 32b C/S certified engineer
Georg Beyer Clausen <gbc.des...@vip.{*word*104}city.dk> a crit dans le message :
37355E08.1B754...@vip.{*word*104}city.dk...

Quote
> D3, BDE 5.01 and paradox 7.0

> Idea: copy data from table to typed file

> Problem: data from memo field missing
> =====================================

> the code:
> -------------------------
>   .
>   .
>   .
>       ordbogTabel.first.
>       ordbogTabel.DisableControls;

>       while NOT (ordbogTabel.eof) do
>         begin
>           NUR.gloseID          := ordbogTabel.Fields[0].AsInteger;
>           NUR.titelID          := ordbogTabel.Fields[1].AsInteger;
>           NUR.Fremmedsprog     := ordbogTabel.Fields[2].AsString;
>           NUR.hovedsprog       := ordbogTabel.Fields[3].AsString;
>           NUR.sek_betydning    := ordbogTabel.Fields[4].AsString;
>           NUR.ordklasse        := ordbogTabel.Fields[5].AsString;
>           NUR.koen             := ordbogTabel.Fields[6].AsString;
>           NUR.kommentar        := ordbogTabel.Fields[7].AsString; //
> memo field *)
>           NUR.FremSample       := ordbogTabel.Fields[8].AsString;
>           NUR.ModerSample      := ordbogTabel.Fields[9].AsString;
>           write(NUF, NUR);
>           ordbogTabel.Next;
>         end;
>         CloseFile(NUF);

>         ordbogTabel.EnableControls;

>   .
>   .
>   .
> ------------

>       *) from the memo field only first 5 characters are copied to
> NUR.kommentar, why?
> The memo field size is set to 240. How do I get more characters from
> the memo field?

> Regards,

> Georg
> gbc*design

Re:copy rows from table to typed file, problem with data from memo field


You need to do something like the following to handle the memo field.

procedure dgExportDelimitedMemo(
            SourceDataSet: TDataSet;
            FieldNum: Integer;
            var AsciiFile: System.Text);
var
  ReadCount:        LongInt;
  StringBuff:       String;
  BlobStream:       TBlobStream;
begin
   {Create the blob stream for this field.}
   BlobStream :=
     TBlobStream.Create(TBlobField(SourceDataSet.Fields[FieldNum]), bmRead);
   SetLength(StringBuff, 1024);
   try
     repeat
       {Read some bytes from the memo.}
       SetLength(StringBuff, 1024);
       ReadCount := BlobStream.Read(StringBuff[1], 1024);
       SetLength(StringBuff, ReadCount);
       {Write the characters to the delimited file.}
       Write(AsciiFile, StringBuff);
     until ReadCount = 0;
   finally
     BlobStream.Free;
   end; {try}
end;

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Other Threads