Ich nutze diese beiden Funktionen, auch in Verbindung mit einem
MSSQL Server:
Delphi-Quellcode:
function TDBRTFReport.LoadFromBlob(const AField: TField; const Stream: TStream): boolean;
var
ResultStr: string;
PResultStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
ResultStr := AField.Value;
PResultStr := PChar(ResultStr);
Stream.Write(PResultStr^, Length(ResultStr));
Stream.Seek(0,0);
Result := true;
except
end;
end;
end;
function TDBRTFReport.SaveToBlob(const Stream: TStream; const AField: TField): boolean;
var
FieldStr: string;
PFieldStr: PChar;
begin
Result := false;
if (Assigned(AField)) and (Assigned(Stream)) then begin
try
Stream.Seek(0,0);
SetLength(FieldStr, Stream.Size);
PFieldStr := PChar(FieldStr);
Stream.Read(PFieldStr^, Stream.Size);
AField.Value := FieldStr;
Result := true;
except
end;
end;
end ;