Using location function on computed field in delphi

How can we use the find function or the same operation function using the calculated field in delphi Tadotable? something like that

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

where samplefield is the calculated field in SampleAdotable. In the normal case, an exception is thrown with this message:

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

Thank you

+5
source share
1 answer

If your SampleField is of type fkCalculated , I don’t think you can use this field as the field whose value you are trying to find when calling Locate .

The reason that Locate calls TCustomADODataSet.LocateRecord , which generates the error you specified, and the reason it makes it, is that SampleField not a field in the ADO Recordset that underlies TCustomADODataSet . An exception occurs when Cursor.MoveNext called.

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

+8
source

Source: https://habr.com/ru/post/1271194/


All Articles