There is a small training (for course) application on Delphi for working with the database, it has basic functionality. It is necessary to expand it by adding a condition that will prohibit the user to add such records to the database that already exist in it, that is, duplicate data.

Adding is done with the help of special delphony combo boxes and ediths for the database, simply because it was easier.

Question: What is the most non-invasive way to check data for duplication in the database?

  1. Catch errors returned by the server when adding and handle the exception?
  2. Create a tricky SQL query (what?), The results of which can be used in the condition?
  3. ???

Database in Access, the database access mechanism is ADO. It is worth considering that it is possible in 2007 Delphi cropped query language and some tricky SQL queries may not work.

    1 answer 1

    This is the standard database engine - a unique index. You form such an index, and the base will throw an exception to you when you try to arrange a duplicate.

    Other ways are wild crutches and they should not be used.

    • To my shame, the first time I heard about unique indexes, everything turned out to be much simpler than I thought. - wrs_47