Board index » delphi » ADO Query parameters: ParamByName doesn't work correctly

ADO Query parameters: ParamByName doesn't work correctly

Hi everyone

In the following SQL sentence of a TADO Query

select * from MDEtiquetas
where
  ((:IdPaquete is null) or (IdPaquete=:IdPaquete))
  and
  ((:IdCampana is null) or (IdCampana=:IdCampana))
  and
  ((:IdCriterio is null) or (IdCriterio=:IdCriterio))
  and
  ((:IdEstadoRemesa is null) or (IdEstadoRemesa=:IdEstadoRemesa))

I was assigning values in this way

      DM.QEtiquetas.Parameters.ParamByName('IdCampana').Value := null;
      DM.QEtiquetas.Parameters.ParamByName('IdCriterio').Value := null;
      DM.QEtiquetas.Parameters.ParamByName('IdPaquete').Value := null;
      DM.QEtiquetas.Parameters.ParamByName('IdEstadoRemesa').Value := 1;

The result was that the second :IdEstadoRemesa was evaluated to NULL instead
of 1.

I haven't found this problem with BDE TQuery.

Is ti an ADO component known bug?. Is there any patch?.

This happened for Delphi 6 + Update 1 + Update2 + RTL 1

Greetings

Flix

 

Re:ADO Query parameters: ParamByName doesn't work correctly


Quote
"FDS" <Fel...@spamfreejazzfree.com> wrote in message

news:3dad28be$1@newsgroups.borland.com...

Quote
> Is ti an ADO component known bug?. Is there any patch?.

TMK, this is not a bug, just a way ADO works. Each parameter must
have a unique name and cannot be used more than once in the
expression.

rb

Re:ADO Query parameters: ParamByName doesn't work correctly


Hey Flix,

This is just a suggession.

Try using [] before and after your fieldname.
    For ex.
      DM.QEtiquetas.Parameters.ParamByName('[IdCampana]').Value := null;

Regards,
EditOR

Re:ADO Query parameters: ParamByName doesn't work correctly


Quote
>  ((:IdPaquete is null) or (IdPaquete=:IdPaquete))
>  and

Bombard's Ado components do not allow you to use a parameter name more than once
in a query.

If you really need to do this there is a very good 3rd party TadoDataset
descendant that has a property you can set to allow you to do this.
http://web.orbitel.bg/vassil/
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:ADO Query parameters: ParamByName doesn't work correctly


How pretty!

Going backward, aren't we? ;-)

Thanks anyway. I'll keep it in my mind.

"Brian Bushay TeamB" <BBus...@Nmpls.com> escribi en el mensaje
news:6n4squceedck9t7mshgcusqmopofts6igf@4ax.com...

Quote

> >  ((:IdPaquete is null) or (IdPaquete=:IdPaquete))
> >  and

> Bombard's Ado components do not allow you to use a parameter name more
than once
> in a query.

> If you really need to do this there is a very good 3rd party TadoDataset
> descendant that has a property you can set to allow you to do this.
> http://web.orbitel.bg/vassil/
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:ADO Query parameters: ParamByName doesn't work correctly


I like that. Thank you.

Other Threads