Board index » delphi » Problems converting dBase files to Paradox files

Problems converting dBase files to Paradox files

Can somebody explain to me how I can copy the content of a
character field (128 car.) of a dBase file to a memofield
in a paradox file.

In a precedent message, Steve Koterski said that we needed
to use a TBlobStream object. I am new to Delphi. I cannot
find clear explanations or examples in the online
documentation to implement that technique.

Second question: is it the same procedure to copy the content
of a memofield of a dBase file to a memofield of a paradox
file.

 

Re:Problems converting dBase files to Paradox files


Quote
Gilles Blais (G.BL...@NFB-ONF.CA) wrote:

: Can somebody explain to me how I can copy the content of a
: character field (128 car.) of a dBase file to a memofield
: in a paradox file.

: In a precedent message, Steve Koterski said that we needed
: to use a TBlobStream object. I am new to Delphi. I cannot
: find clear explanations or examples in the online
: documentation to implement that technique.

: Second question: is it the same procedure to copy the content
: of a memofield of a dBase file to a memofield of a paradox
: file.

To insert data into a BLOB field, the data must be of type PChar. The
Write method of the TBlobStream object would then be used to write the
PChar value to the BLOB field.

In the example below, Table1 is connected to a dBASE table, which has a
String type field (TEXT) as the second field. Table2 is connected to a
Paradox table, in which there is a memo field, second field in the
structure. This routine will copy the String data from the dBASE field
into the Paradox memo field.

procedure TForm1.Button1Click(Sender: TObject);
var
  BS: TBlobStream;
  PC: array [0..255] of Char;
  b: Byte;
begin
  Table2.Edit;
  b := 255;
  BS := TBlobStream.Create(TBlobField(Table2.Fields[1]), bmWrite);
  FillChar(PC, b, #0);
  try
    StrPCopy(PC, Table1.Fields[1].AsString);
    BS.Write(PC, b);
  finally
    BS.Free;
  end;
  Table2.Post;
end;

--
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Steve Koterski               _/   The opinions expressed here are    _/
_/ koter...@borland.com         _/         exclusively my own           _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Other Threads