Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using locate function on calculated field in delphi

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

like image 433
nader Avatar asked Aug 24 '17 12:08

nader


1 Answers

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.

like image 181
MartynA Avatar answered Nov 04 '22 13:11

MartynA