Error converting variant to double [Delphi XE + IBObjects 4.9.12]

My configuration:

Delphi xe
Firebird 2.1
IBObjects 4.9.12
Windows 7 64bits

I get an exception when I try to set a value for the IBOQuery parameter ("Failed to convert the variant of type (UnicodeString) to type (Double)").

An exception arises from the TIB_Column.SetAsVariant procedure in IB_Components.pas (line 42795). To create this situation, just try passing the string to the date parameter:

myQuery.paramByName('mydate').AsString := DateToStr(IncDay(Now,5));

Over the past 25 days, I have been trying to resolve this situation, but I have no answers on the IBO support list.
Does anyone have an idea?

+4
source share
1 answer

IBObjects architecture converts (at runtime) all parameters, fields, etc. in String or Variants. If your parameter "mydate" is of type "DateTime" (numeric), you must fill it with a value of type responder. It is not logic to populate a “numeric” type parameter with a string ...

try it

myQuery.paramByName ('mydate'). AsDateTime: = Now + 5; // this is the same as David's answer.

or

myQuery.paramByName ('MyDate') AsFloat :. = Now + 5; // or IncDay (now, 5)

Best wishes,
Radu

+3
source

Source: https://habr.com/ru/post/1336775/


All Articles