Repeated parameters in MSQuery

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
danilo.abranches
Posts: 8
Joined: Mon 08 Sep 2014 16:39

Repeated parameters in MSQuery

Post by danilo.abranches » Mon 03 Nov 2014 21:00

Hi,

I am having the following problem to set some parameters in a MSQuery. When own parameters that are repeated in the query and dynamically create (CreateParam or ParseSQL), the second value is NULL when seen in Profiler.

Example:

Code: Select all

MSQueryPl1.ParamCheck := False;
MSQueryPl1.SQL.Text := 'select * from table where field = :field and '''' <> :field';
MSQueryPl1.Params.ParseSQL(MSQueryPl1.SQL.Text, True);
MSQueryPl1.ParamByName('field', 'value', ftString);
The query is generated with the last parameter NULL. If i make a loop and set the two parameters, it works.

This way it works:

Code: Select all

MSQueryPl1.ParamCheck := True;
MSQueryPl1.SQL.Text := 'select * from table where field = :field and '''' <> :field';
MSQueryPl1.ParamByName('field', 'value', ftString);
Does anyone know why this happens?


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

Re: Repeated parameters in MSQuery

Post by AlexP » Tue 04 Nov 2014 10:12

If you are using Lazarus, then when using similar parameter names you should set a value for each parameter entry. This is due to implementation when working with parameters in Lazarus. In Delphi, the value is set for both parameters.

danilo.abranches
Posts: 8
Joined: Mon 08 Sep 2014 16:39

Re: Repeated parameters in MSQuery

Post by danilo.abranches » Tue 04 Nov 2014 12:39

Thank you.

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

Re: Repeated parameters in MSQuery

Post by AlexP » Wed 05 Nov 2014 05:55

If you have any further questions, feel free to contact us.

Post Reply