Hi all.
I'm having a problem with a blob-field in dbf, when i try to dump some data from firebird 2.0 to dbf, all fields except blobs are written correctly to dbf-file... I can't seem to figure it out, what am I missing?!?
var
I,J: integer;
S: string;
StrmD,StrmS: TStream;
begin
Memo1.Clear;
zConnection1.Connect;
ZQuery1.SQL.Text:= 'select * from diary;';
ZQuery1.Open;
Memo1.Lines.Add('Source dataset opened...');
Dbf1.FieldDefs.Clear;
for I:= 0 to ZQuery1.FieldDefs.Count - 1 do begin
Dbf1.FieldDefs.Add(ZQuery1.FieldDefs[I].Name,ZQuery1.FieldDefs[I].DataType);
S:= S+' | '+ZQuery1.FieldDefs[I].Name;
end;
Memo1.Lines.Add(S);
Memo1.Lines.Add('Creating destination dataset...');
Dbf1.CreateTable;
Dbf1.Open;
ZQuery1.First;
Memo1.Lines.Add('Dumping data to Dbf...'); //exit;
while not ZQuery1.EOF do begin
Dbf1.Insert;
Dbf1.FieldByName('id_diary').AsInteger:= ZQuery1.FieldByName('id_diary').AsInteger;
Dbf1.FieldByName('id_locatio').AsInteger:= ZQuery1.FieldByName('id_location').AsInteger;
Dbf1.FieldByName('adate').AsInteger:= ZQuery1.FieldByName('adate').AsInteger;
Dbf1.FieldByName('acomment').AsString:= AnsiToUtf8(ZQuery1.FieldByName('acomment').AsString);
Dbf1.FieldByName('haspics').AsInteger:= ZQuery1.FieldByName('haspics').AsInteger;
StrmD:= Dbf1.CreateBlobStream(Dbf1.FieldByName('atext'),bmReadWrite);
StrmS:= ZQuery1.CreateBlobStream(ZQuery1.FieldByName('atext'),bmRead);
try
StrmS.Position:= 0;
J:= StrmS.Size; Memo1.Lines.Add('Source stream size: '+inttostr(J));
StrmD.CopyFrom(StrmS,StrmS.Size);
StrmD.Position:= 0;
J:= StrmD.Size; Memo1.Lines.Add('Destination stream size: '+inttostr(J));
Dbf1.Post;
finally
StrmS.Free;
StrmD.Free;
end;
// Dbf1.Post;
ZQuery1.Next;
Application.ProcessMessages;
Sleep(10);
end;
Memo1.Lines.Add('Done dumping data to Dbf, cleaning up.');
Dbf1.Close;
ZQuery1.Close;
ZConnection1.Disconnect;
TIA Benny