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
Delphi

Avatar of undefined
Last Comment
plumothy
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
plumothy
Flag of United Kingdom of Great Britain and Northern Ireland image

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...
Avatar of plumothy
plumothy
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

It works alright with BDS 2006.

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

Anyone got XE4?
Avatar of plumothy
plumothy
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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
Avatar of atul_parmar
atul_parmar
Flag of India image

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?
Avatar of Guillaume80
Guillaume80
Flag of France image

FYI, your test project works well on my machine (Win 7 + Delphi XE2)
Avatar of plumothy
plumothy
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Delphi
Delphi

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

60K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo