將FASTREPORT報表從數據庫存入取出

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:

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;
發佈了1 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章