Link to home
Start Free TrialLog in
Avatar of plumothy
plumothyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Delphi TClientDataset cannot Lookup 15360

I must be doing something wrong - but I just can't see what it is...

I use Delphi XE3 on Win 7.

In TClientDataset (A) I have an integer field which looks up a value from an integer field in TClientDataset (B).

This works just fine UNLESS the value of the integer in (B) equals 15360; in this case nothing shows in the lookup integer field (A). But, if I lookup the same integer and return it to a string field then it works OK.

What is so special about the number 15360?

The attached sample project demonstrates this problem.

500 points if you can put me out of my misery!
TestCDSLookup.zip
Avatar of atul_parmar
atul_parmar
Flag of India image

Seems to work for me. FYI, I tried with Delphi 2007 and Delphi XE on XP.
Avatar of plumothy

ASKER

Thanks for trying it out. I have just tried it in Delphi XE on Win 7 and it works OK.

I will dust off an old machine with BDS 2006 and try that...
It works alright with BDS 2006.

So far, it's just XE3 on Win 7.

Anyone got XE4?
I have done some more testing and discovered that it is nothing to do with Lookup.

You simply cannot assign the number 15360 to a TClientDataset integer field. I have tried FieldByName().Value and FieldByName().AsInteger. All other numbers I have tried are OK - just 15360 (so far) fails.

(InsertRecord([15360]) does work OK.)

The attached project demonstrates this. I use InsertRecord to add a few records which set the field called "X" ranging from 15356 through to 15363. The calculated field called "XCalc" is set to the value of X and the calculated field called "X15360" is set directly to 15360. The value 15360 is never displayed in the grid for columns XCalc and X15360.

I can't believe what I am seeing - there must be an explanation for this.
Test15360.zip
Is it XE3? If you have source, you can debug and see what is wrong. Also, the issue may be with dbgrid too. Would you use a data bound control e.g. DBEdit to see whether it displays correctly?
FYI, your test project works well on my machine (Win 7 + Delphi XE2)
Yes, this is Delphi XE3.

It is nothing to do with DBGrid or any other bound control (ie it is not a display problem).

I now have a version of my test project (attached) which has no bound controls at all.

I have discovered that every integer multiple of 256 (including zero) cannot be assigned to an integer field.

Can someone test this in Delphi XE4 (I don't have it)?
Test256.zip
ASKER CERTIFIED SOLUTION
Avatar of plumothy
plumothy
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial