TiagoTecchio
TiagoTecchio

Reputation: 308

Error converting variant into 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 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 got no answers.
Someone have an idea?

Upvotes: 4

Views: 4857

Answers (1)

RBA
RBA

Reputation: 12584

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

Upvotes: 3

Related Questions