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!

Avatar of undefined
Last Comment

8/22/2022 - Mon

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

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?
Your help has saved me hundreds of hours of internet surfing.

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.

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)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

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)?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question