Page 1 of 1

TZParams compatibility Fastreport

Posted: 16.09.2021, 15:50
by ekhirs5a
it would be possible because of compatibility

TZParmas
property Bound: Boolean read FBound;

in TParams
property Bound: Boolean read FBound write FBound;


{ Bound should be True in design mode }

Code: Select all

  procedure frxParamsToZParams(Query: TfrxCustomQuery; Params: TZParams);
  var
    i: Integer;
    Item: TfrxParamItem;
  begin
    for i := 0 to Params.Count - 1 do
      if Query.Params.IndexOf(Params[i].Name) <> -1 then
      begin
        Item := Query.Params[Query.Params.IndexOf(Params[i].Name)];
        Params[i].Clear;
        Params[i].DataType := Item.DataType;
        { Bound should be True in design mode }
        if not (Query.IsLoading or Query.IsDesigning) then
          Params[i].Bound := False
        else
        begin
          if Item.Expression <> '' then
            Params[i].Value := 0;
          Params[i].Bound := True;
        end;

        if Trim(Item.Expression) <> '' then
          if not (Query.IsLoading or Query.IsDesigning) then
            if Query.Report <> nil then
            begin
              Query.Report.CurObject := Query.Name;
              Item.Value := Query.Report.Calc(Item.Expression);
            end;
        if not VarIsEmpty(Item.Value) then
        begin
          Params[i].Bound := True;
          if Params[i].DataType in [ftDate, ftTime, ftDateTime] then
            Params[i].Value := Item.Value
          else
            Params[i].Value := Item.Value;
        end;

      end;
  end;
	
Best regards,

Roland

Re: TZParams compatibility Fastreport

Posted: 17.09.2021, 09:19
by marsupilami
Hello Roland,

I am not sure if it makes sense to make Bound writable. Zeos doesn't do anything with this information. This probably is why EgonHugeist made it Read Only. From a Zeos Point of View you just could skip writing to bound.

If we make bound writable we would need some functionality that depends on it. The documentation on Bound from Embarcadero says:
Datasets that represent queries and stored procedures use the value of Bound to determine whether to assign a default value for the parameter. If Bound is false, datasets that represent queries attempt to assign a value from the dataset indicated by their DataSource property. Similarly, when Bound is false, datasets that represent stored procedures attempt to supply a value directly from the server.
I am not sure what Zeos should do if one sets Bound to False on a TZQuery. Where should it get a default value from? For stored procedures we could check the meta data if there is a defauilt value there. But that also is nos implemented currently.

So - I suggest to just skip writing to bound.

Best regards,

Jan

Re: TZParams compatibility Fastreport

Posted: 18.09.2021, 06:44
by aehimself
You can try to use .Value := null instead of .Bound.
If FastReport depends on .Bound you can disable ZParams in your project so it'll use the standard TParams instead.