Date parameters in query don't work with 3.80.0.36

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
peetjet
Posts: 8
Joined: Fri 04 Mar 2005 10:45
Location: Netherlands
Contact:

Date parameters in query don't work with 3.80.0.36

Post by peetjet » Wed 04 Apr 2007 12:46

In a delphi program I use date parameters in a query.

Like this:
mq.SQL.Text := 'SELECT * FROM TABLE WHERE A_DATE >= :P_DATE';
mq.Prepare;
mq.ParamByName('P_DATE').Value := DateOf(Some_Date);
mq.Open;

This used to work fine, but after upgrading to SDAC 3.80 this doesn't work
anymore.

I already worked around it by using literal date values, but I still would like a comment on this, because I have more projects that will certainly be affected by this problem.

Peet Terluin

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Wed 04 Apr 2007 14:38

You should specify parameters data type before calling the Prepare method.
For example:

Code: Select all

  mq.SQL.Text := 'SELECT * FROM TABLE WHERE A_DATE >= :P_DATE';
  mq.ParamByName('P_DATE').DataType := ftDateTime;
  mq.Prepare;

peetjet
Posts: 8
Joined: Fri 04 Mar 2005 10:45
Location: Netherlands
Contact:

Post by peetjet » Wed 04 Apr 2007 18:33

Thanks.

Post Reply