Query.Params.count differs between BDE and UniDAC

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JoelH
Posts: 7
Joined: Thu 01 Apr 2010 10:48
Location: Germany

Query.Params.count differs between BDE and UniDAC

Post by JoelH » Thu 21 Apr 2016 09:15

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: :(

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Thu 21 Apr 2016 09:52

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.

JoelH
Posts: 7
Joined: Thu 01 Apr 2010 10:48
Location: Germany

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

Post by JoelH » Thu 21 Apr 2016 11:01

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Thu 21 Apr 2016 11:42

No, there is no such capability.

Post Reply