using locate function on calculated field in delphi
Asked Answered
H

1

5

How can we use locate function or a same operation function using a calculated field in delphi Tadotable? something like this

SampleAdotable.locate('samplefield',text,[lopartialkey]);

where samplefield is a calculated field in SampleAdotable.In normal case an exception with this message is created:

Item can not be found in the collection corresponding to the requested name or ordinal

thank you

Hesperian answered 24/8, 2017 at 12:38 Comment(0)
W
8

If your SampleField is of type fkCalculated, I don't think you can use this field as a field whose value you try to locate in a call to Locate.

The reason is that Locate calls TCustomADODataSet.LocateRecord which generates the error you quote and the reason it does is that SampleField is not a field in the ADO Recordset underlying the TCustomADODataSet. The exception occurs in the call to Cursor.MoveNext.

To do what you want, try constructing a calculated field in the SQL expression used to obtain the row data from the database. Depending on the server you are using, you may need to use a TAdoQuery instead of a TAdoTable to get the rows.

Worrywart answered 24/8, 2017 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.