Page 1 of 1

Query.Params.count differs between BDE and UniDAC

Posted: Thu 21 Apr 2016 09:15
by JoelH
I hope the subject is okay. I'am porting a very old Delphi 4 with BDE Project to XE7 with UniDAC.

And now i run into a the following range check error.

The original code is like this sample

Code: Select all

with query1 do
begin 
  sql.add('SELECT foo, bar from ( ');
  sql.add(' SELECT foo, bar FROM TABLE1 WHERE xyz = :p1 ');  
  sql.add(' UNION ALL ');
  sql.add(' SELECT foo, bar FROM TABLE2 WHERE XYZ = :p1 ) ');
  params[0].asString := edit1.text;
  params[1].asString := edit1.text;
end;
But with UniDac this works no more, because the TUniQuery says correctly that query1.params.count = 1 and not 2.

My question now is, can i change the behavior of UniDac or do i have to check all these paramcounts and eliminate the duplicates?

I know option two is the better/correct way, but there is plenty of this kind of code in the project. :roll: :(

Re: Query.Params.count differs between BDE and UniDAC

Posted: Thu 21 Apr 2016 09:52
by AlexP
Hello,

If parameter names are the same, then in UniDAC they will be a single parameter. If you want to assign different values, you should set different parameter names.

Re: Query.Params.count differs between BDE and UniDAC

Posted: Thu 21 Apr 2016 11:01
by JoelH
Hi Alex,

i never would use such unnamed PArametercode, i prefer ParamByName, but in this case, it is not my code, it is only my problem :wink:

My question is if there exists an UniDac-Option that the Paramcount returns 2, instead of 1. in this case. But i think there is no such option.

Re: Query.Params.count differs between BDE and UniDAC

Posted: Thu 21 Apr 2016 11:42
by AlexP
No, there is no such capability.