Subject | Re: Error when assigning a value .. type conversion problem with dates in both IBO 4.9.9 and 4.9.10 |
---|---|
Author | fisch50de |
Post date | 2010-08-19T17:04:52Z |
--- In IBObjects@yahoogroups.com, "Adrian Wreyford" <wreymed@...> wrote:
A workaround can be to check, if the field is a date/time/datetime field and convert the value with the right locales yourself.
--
Andreas
>It's not IBO's fault, it's Delphi's Variant conversion methods.
> Hi Jason,
>
> Its me and the variants again.
>
> This time I'm stumped.
>
> I'm parsing a CSV into a Query.
>
> The fields in the CSV are all strings, and stored in a stringlist.
>
> I then assign these to the fileds in the query, the fieldnames also stored in a list.
>
> IB_QueryBlup.FieldByName(BlupColList[r]).Value := FieldList.Items[r-1];
>
> When I send the field BLUPDATE, a date field, ie the value '1988/02/05' it throws the error:
>
> EVariantTypeCastError with message ' Could not convert variant of type (UnicodeString) into type (Double).
>
> And occurs in: IB_Components
> 42510: procedure TIB_Column.SetAsVariant( const NewValue: Variant );
>
> and especially at line: 42660-1
> SQL_TYPE_DATE,
> SQL_TYPE_DATE_: if AsDate <> Trunc( NewValue ) then
>
> NewValue = '1988/02/05', and this is where the problem comes in. It appears to be expecting the data value as double, and not the date string that we are actually passing it.
>
> Your routine should probably first check if the date value passed is a TDate, or a human readable representation of the date ie '1988/02/05'.
>
> Hope you can help.
>
> This is quite a problem for me at the moment.
>
> Regards
>
> Adrian
>
>
>
A workaround can be to check, if the field is a date/time/datetime field and convert the value with the right locales yourself.
--
Andreas