А не проще было вместо всего этого:
Код:
SQL.Add('WHERE BSO.Num BETWEEN iif(:Num_Start is null, Num, :Num_Start) and iif(:Num_End is null, Num, :Num_End)');
if (Trim(Num_S) = '') or (Trim(Num_E) = '') then
begin
Parameters.ParamByName('Num_Start').Value := Null;
Parameters.ParamByName('Num_End').Value := Null;
end
else
begin
Parameters.ParamByName('Num_Start').Value := Trim(Num_S);
Parameters.ParamByName('Num_End').Value := Trim(Num_E);
end;
Open;
сделать так:
Код:
if (Trim(Num_S) <> '') and (Trim(Num_E) <> '') then
SQL.Add('WHERE BSO.Num BETWEEN ''' + Trim(Num_S) + ''' and '''+ Trim(Num_E))+'''';
Open;