Page 1 of 1

D2007 and firebird Datatime parameter error

Posted: Mon 12 Nov 2007 13:58
by Fabioda
Hi,
I have a tsqlquery with an insert statement. One of the fields is a timestamp. I use parameters to set field values, and for the timestamp field the statement is:
q.ParamByName('DATE_FIELD').AsDateTime := Now

When I execute the statement with ExecSQL i get a "No value for parameter DATE_FIELD.
It used to work with UIB Dbexpress driver I was using with D2006. Any clue? I even tried using .Value instead of .AsDateTime

TIA,
Fabio Dalle Ave

Posted: Mon 12 Nov 2007 14:07
by Fabioda
To clarify further: I'm using the latest dbexpress driver 2.00.5.
Right now I got away setting CURRENT_TIMESTAMP directly in the query. But I have another application with the same error (but this time the timestamp is input by the user)..

Fabio Dalle Ave

Posted: Mon 12 Nov 2007 15:05
by Plash
You should use the following code for Delphi 2007:

Code: Select all

  SQLQuery.ParamByName('DATE_FIELD').DataType := ftTimeStamp;
  SQLQuery.ParamByName('DATE_FIELD').Value := Now;

Posted: Mon 12 Nov 2007 15:16
by Fabioda
Plash wrote:You should use the following code for Delphi 2007:

Code: Select all

  SQLQuery.ParamByName('DATE_FIELD').DataType := ftTimeStamp;
  SQLQuery.ParamByName('DATE_FIELD').Value := Now;
Thanks.
I tried that but didn't work. Same error.

Fabio

Posted: Mon 12 Nov 2007 15:34
by Plash
You should use exactly this code. If you set the DataType property to ftTimeStamp but assign a value using the AsDateTime property, the error will occur.

Posted: Mon 12 Nov 2007 15:39
by Fabioda
Ok thanks...
Indeed I had left .AsDateTime... Changing it to .Value got it to work.

Thanks again.

Fabio