function that returns the name of the key field of a query (tfdquery), Delphi XE8

Asked

Viewed 282 times

1

I’m preparing a CRUD in Delphi and need to do a function to find the key field (Keyfield) of a certain record located in the query. The idea is to replace the id field required by Locate with this function and leave the dataset set set set to take over any query in the Heirs(inherited). I’ll demonstrate the code to see if you understand me:

ds_Crud.DataSet.Locate('tpdoc_id',ds_Query.DataSet.FieldByName('tpdoc_id').Value,[loCaseInsensitive,loPartialKey]);
  1. My ds_Crud is a TFDQUERY that performs the modifications in the database;
  2. My ds_Query is a TFDQUERY that executes the queries;

My data tabsheet of this form is triggered when the record is located by ds_Query and is located by the primary key in ds_Crud that goes into edit mode to perform EDIT or DELETE.

The problem is that I cannot keep typing the code 'id' each time I perform the query in inherited Forms, I need a function that returns the name of the key field to filter the record in the CRUD Dataset, which is virtual and abstract of the type (function GetNomeKeyFiled: String;virtual;abstract;) to take the position of tpdoc_id in the code line above locate, or something that solves this problem.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.