开发者

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

开发者 https://www.devze.com 2023-02-06 22:25 出处:网络
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 to a IBOQuery parameter (\"Could not convert variant of type (UnicodeString) i

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 to a IBOQuery parameter ("Could not convert variant of type (UnicodeString) into type (Double)").

The exception is raised from TIB_Column.SetAsVariant procedure in IB_Components.pas (line 42795). To create this situation, just try to pass a string to a date parameter:

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

During last 25 days I'm trying to solve this situation, but in IBO support list I've开发者_StackOverflow中文版 got no answers.

Someone have an idea?


IBObjects's architecture is converting(at a moment of execution) all parameters, fields, etc to String or Variants. If your 'mydate' parameter is 'DateTime'(numeric) type then you must fill it up with a corespondent type value. Is not logic to fill an 'numeric' type parameter with a string...

try this

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

or

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

Best regards,
Radu

0

精彩评论

暂无评论...
验证码 换一张
取 消