Adding record avoiding duplicates of a chosen field lazarus / 16-Databases ---------------------------------------------------------------------- jshand2010 · 2013-01-26 09:59 hi there, i have included my source code, but am unsure how to check the database for duplicates before comitting to database. Please help ---------------------------------------------------------------------- goodname · 2013-01-26 15:55 This can be done with a unique index on the database. Check your database documentation for how to do this. Your code should catch database thrown errors. If you use SQLdb and applyUpdates there is an OnUpdateError event otherwise a try except block should do it. ---------------------------------------------------------------------- jshand2010 · 2013-01-26 22:25 unique indexing?  how do you do this is tsqlquery code?  because i've tried to use a as an integer, but you actually need to assign it to a number, hence throwing an error on duplicates. ---------------------------------------------------------------------- BigChimp · 2013-01-27 10:45 You don't set a unique index in Pascal code but in your database. http://www.w3schools.com/sql/sql_create_index.asp Note: haven't looked at your code...