Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Could not convert variant of type (Array Byte) into type (Integer)
Tue, May 26 2015 1:24 AMPermanent Link

Adam H.

Hi,

I'm in the process of trying to update one of my projects from Delphi
2007 to Delphi XE2 and have come across the following error:

"Could not convert variant of type (Array Byte) into type (Integer)"

The code which this is executing on is:

if Q1.Fields[i].value <> Q2.Fields[i].value


What's strange is that Q2 is simply an exact copy of the data before
it's edited.

ie:

select * into Memory\Q2 from Mytable where ID = 123

Then Q1 is similar:

select * from Mytable where ID = 123

I then compare the two to see if any changes have been made.

This works fine as I go through the fields until I hit a field that is a
blob. Then it errors out as per above.

This script works fine in Delphi 2007. I know that XE2 has some changes
to support unicode, etc but I'm not sure how that should affect this code.

This is using DBISAM 4.41 b1

In my instance the process runs through the whole fieldcount of the
dataset, so the datatype will be different from one to the next. (ie,
integers, strings, dates and blobs).

Thanks & Regards

Adam.
Tue, May 26 2015 2:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


Since I'm still using D2006 I don't have direct experience but generally when I've had those types of errors its because the field is null.

Roy Lambert
Tue, May 26 2015 3:09 AMPermanent Link

Adam H.

Hi Roy,

> Since I'm still using D2006 I don't have direct experience but generally when I've had those types of errors its because the field is null.

Yeah - I've already had issues with the way null's are handled differently.

ie: length(table1field1.value) used to return 0 in D2007, and now raises
an exception if the value is null in XE2.

I swear Delphi 7 (with coderush Smile) was the best IDE I've had, and ever
since then things have gotten buggier. I paid for XE2 primarily to get
over the issues I had in D2007 and found more new bugs and issues than
it corrected.

Anyway - back to the question in hand, in this instance the value is not
null. It contains the exact same value, but it's definitely not null.

In my searches I've just come across QC 116168 which appears to have a
very similar issue with XE2, XE3 and XE4 and is still open with no fix! Frown

Cheers

Adam.
Tue, May 26 2015 4:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


What about trying .AsString rather than .Value. I think all of the field types coerce to a string.

Roy Lambert
Tue, May 26 2015 7:38 PMPermanent Link

Adam H.

Hi Roy,

> What about trying .AsString rather than .Value. I think all of the
> field types coerce to a string.

Thanks for that. I've put in code to use .asstring for the blob fields,
but left the others as is (so the system can still tell differences
between null values and those not null).

I'm not sure just how many places in code this will effect, but I guess
I'm going to find out.

Once again, thanks for your help!

Cheers

Adam
Image