Check if record already exists in DB Grid Delphi

Asked

Viewed 392 times

-1

Good afternoon, you guys. The language I’m using is Delphi 4. I have a question on how to check if a record already exists in DB Grid. The values I want to enter in Dbgrid will be typed in a DB Edit. The table has two primary keys. If the set of primary keys is equal to some database record, the system will prevent the insertion of the record in Dbgrid.

1 answer

0


If you have a primary key, the database will prevent you from entering that key again, and the application will launch a "Primary key breach" error, if you really want to search the table when the user enters the key in the TEdit, then you will need to write the code in the event handler OnChange editing using the function Locate(). By the way, the search is on Tdataset not on the Tdbgrid component

Browser other questions tagged

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