Change FIBQuery SQL text runtime before report show or execution
Hi All, please help me..
I have made a report in runtime where I save the report in the table and called if necessary.
the report contained FIBQuery1 by default SQL text "SELECT * FROM SP_JUALPERBARANG4 (: PERIODE,: TGLFIRST,: TGLLAST)"
I want to add a WHERE clause in runtime eg be
"SELECT * FROM SP_JUALPERBARANG4 (: PERIODE,: TGLFIRST,: TGLLAST) WHERE NAMABARANG CONTAINING ELA "
My problem is when the report is displayed appears error "can not change the database because the dataset open", but already I close and open FIBQuery.
The following piece of code that I have made.
I use FastReport 4.14, Delphi 7, Firebird 2.5
Thx b4.
Sorry for my bad english..
I have made a report in runtime where I save the report in the table and called if necessary.
the report contained FIBQuery1 by default SQL text "SELECT * FROM SP_JUALPERBARANG4 (: PERIODE,: TGLFIRST,: TGLLAST)"
I want to add a WHERE clause in runtime eg be
"SELECT * FROM SP_JUALPERBARANG4 (: PERIODE,: TGLFIRST,: TGLLAST) WHERE NAMABARANG CONTAINING ELA "
My problem is when the report is displayed appears error "can not change the database because the dataset open", but already I close and open FIBQuery.
The following piece of code that I have made.
procedure TFCetak.sBitBtn1Click(Sender: TObject);
var
  frx: TfrxReport;
  frxFIBDB : TfrxFIBComponents;
  frxFIBQ : TfrxFIBQuery;
  st: TStream;
begin
  frx      :=  TfrxReport.Create(Self);
  frxFIBDB  :=  TfrxFIBComponents.Create(Self);
  frxFIBDB.DefaultDatabase  := DM.db;
 Â
  DM.Laporan.Open;
  if DM.Laporan.Locate('Nama',Caption,[]) then
  begin
    st:=DM.Laporan.CreateBlobStream(DM.LaporanSOURCE,bmRead);
    frx.LoadFromStream(st);
    st.Free;
  end;
 Â
  frxFIBQ := (TfrxFIBQuery(frx.FindComponent('FIBQuery1')));
  ShowMessage(frxFIBQ.SQL.Text); // SELECT * FROM SP_JUALPERBARANG4(:PERIODE,:TGLFIRST,:TGLLAST)
 Â
  if not (frxFIBQ=Nil) then
  begin
    frxFIBQ.Close;
    frxFIBQ.SQL.Add('WHERE NAMABARANG CONTAINING ''ELA'' ');
    ShowMessage(frxFIBQ.SQL.Text); // SELECT * FROM SP_JUALPERBARANG4(:PERIODE,:TGLFIRST,:TGLLAST) WHERE NAMABARANG CONTAINING ELA
    frxFIBQ.Open;
   Â
    frx.Variables['PERIODE']  := _CurrentPeriode;
    frx.Variables['TGLFIRST'] := pTgl1.Date;
    frx.Variables['TGLLAST']  := pTgl2.Date;
    frx.ShowReport();
  end;
end;
I use FastReport 4.14, Delphi 7, Firebird 2.5
Thx b4.
Sorry for my bad english..
Comments