var
S: TStream;
begin
if (DM1.CDSREPORTS.Active) and (DM1.CDSREPORTS.Fields[0].AsInteger <> Null) then
if OpenDialog.Execute then
try
DM1.CDSREPORTS.Edit;
S:= TFileStream.Create(OpenDialog.FileName, fmOpenRead);
TBlobField(DM1.CDSREPORTS.Fields[2]).LoadFromStream(S);
DM1.CDSREPORTS.Post;
DM1.CDSREPORTS.ApplyUpdates(0);
finally
S.Free;
end;
Let's assume, you have a Blob Filed called "Report" and the table Name is "Reports":
On the frxDesigner object, go to the Event "OnSaveReport" and put this code...
function TForm1.frxDesigner1SaveReport(Report: TfrxReport;
SaveAs: Boolean): Boolean;
var template : TStream;
begin
template := TMemoryStream.Create;
template.Position := 0;
frxReport1.SaveToStream(template);
Reports.Edit;
try
Reports.DisableControls;
(Reports.FieldByName('Report') as TBlobField).LoadFromStream(template);
Reports.Post;
finally
Reports.EnableControls;
end;
end;
now, let's assume you have a button to print your report.... on the event "Onclick" put this code:
Comments
Modify your report and then save the report to the blob fields (via the stream)
That's all
In Delphi2005 I made this mode:
var
S: TStream;
begin
if (DM1.CDSREPORTS.Active) and (DM1.CDSREPORTS.Fields[0].AsInteger <> Null) then
if OpenDialog.Execute then
try
DM1.CDSREPORTS.Edit;
S:= TFileStream.Create(OpenDialog.FileName, fmOpenRead);
TBlobField(DM1.CDSREPORTS.Fields[2]).LoadFromStream(S);
DM1.CDSREPORTS.Post;
DM1.CDSREPORTS.ApplyUpdates(0);
finally
S.Free;
end;
On the frxDesigner object, go to the Event "OnSaveReport" and put this code...
function TForm1.frxDesigner1SaveReport(Report: TfrxReport;
SaveAs: Boolean): Boolean;
var template : TStream;
begin
template := TMemoryStream.Create;
template.Position := 0;
frxReport1.SaveToStream(template);
Reports.Edit;
try
Reports.DisableControls;
(Reports.FieldByName('Report') as TBlobField).LoadFromStream(template);
Reports.Post;
finally
Reports.EnableControls;
end;
end;
now, let's assume you have a button to print your report.... on the event "Onclick" put this code:
procedure TForm1.btnPrintClick(Sender: TObject);
var template : TStream;
begin
template := Reports.CreateBlobStream(Reports.FieldByName('Report'), bmRead);
template.Position := 0;
try
frxReport1.LoadFromStream(template);
frxReport1.ShowReport;
finally
template.Free;
end;
end;
Hope this helps.
Regards.