Check if record already exists in DB Grid Delphi

-1

Good afternoon, everyone. The language I am using is Delphi 4. I am having a question on how to check if a record already exists in DB Grid. The values I want to insert into the DBGrid will be typed in a DB Edit. The table has two primary keys. If the primary key set equals some bank record, the system will prevent the record from being inserted into the DBGrid.

    
asked by anonymous 21.09.2018 / 19:49

1 answer

0

If you have a primary key, the database will prevent you from entering this key again, and the application will throw a "Primary Key Violation" error if you really want to search the table when the user types the key in the TEdit , then you will need to write the code in the OnChange event handler of the edit using the Locate () . By the way, the search is in TDataSet not in the TDBGrid component

    
23.09.2018 / 17:55