Subject | TIBOQuery.TBlobField - Saving to Stream |
---|---|
Author | Luis Semedo Duarte |
Post date | 2007-09-17T16:11:55Z |
Hello all.
Well i have another problem with blob fields. :-(
I have a procedure that uses a dataset (a TIBOQuery), finds the
blobfield by name and saves it to a stream, or so i thought! I realy
dont know why but the TBlobField.SaveToStream(TMemoryStream) does
nothing. But if instead i use TBlobField.SaveToFile('c:\file.txt') it
works perfectly.
Here's the code:
procedure TUser.LoadDefs;
var
i: integer;
ms: TMemoryStream;
begin
// FDefsDataSet is a TDataSet from the User class. When the user
// class is initiated the FDefsDataSet field has its value assigned
// to a TIBOQuery.
if (FDefsDataSet.RecordCount = 0) then Exit;
FDefsDataSet.First;
ms := TMemoryStream.Create;
for i := 0 to (FDefsDataSet.RecordCount-1) do
begin
FDefinitions.Clear;
with FDefinitions.Add do
begin
FClassName := FDefsDataSet.FieldByName('CLASS').AsString;
(FDefsDataSet.FieldByName('DEF') as TBlobField).SaveToStream
(ms);
FUserData := FDefsDataSet.FieldByName('AUDIT_DATA').AsDateTime;
FUserDsc := FDefsDataSet.FieldByName('AUDIT_USER_DSC').AsString;
end;
FDefsDataSet.Next;
end;
end;
Any help on this matter would be mutch appreciated!
Thx
Luis Semedo Duarte
Well i have another problem with blob fields. :-(
I have a procedure that uses a dataset (a TIBOQuery), finds the
blobfield by name and saves it to a stream, or so i thought! I realy
dont know why but the TBlobField.SaveToStream(TMemoryStream) does
nothing. But if instead i use TBlobField.SaveToFile('c:\file.txt') it
works perfectly.
Here's the code:
procedure TUser.LoadDefs;
var
i: integer;
ms: TMemoryStream;
begin
// FDefsDataSet is a TDataSet from the User class. When the user
// class is initiated the FDefsDataSet field has its value assigned
// to a TIBOQuery.
if (FDefsDataSet.RecordCount = 0) then Exit;
FDefsDataSet.First;
ms := TMemoryStream.Create;
for i := 0 to (FDefsDataSet.RecordCount-1) do
begin
FDefinitions.Clear;
with FDefinitions.Add do
begin
FClassName := FDefsDataSet.FieldByName('CLASS').AsString;
(FDefsDataSet.FieldByName('DEF') as TBlobField).SaveToStream
(ms);
FUserData := FDefsDataSet.FieldByName('AUDIT_DATA').AsDateTime;
FUserDsc := FDefsDataSet.FieldByName('AUDIT_USER_DSC').AsString;
end;
FDefsDataSet.Next;
end;
end;
Any help on this matter would be mutch appreciated!
Thx
Luis Semedo Duarte