Can anyone help me with an 'IF' statement that will prevent saving a duplicate record in MSSQL

Re: preventing duplicate records from Delphi 80 80

this depends on how you have designed your database. you should have an ID field which is the number of record and this to be an PK.
in this way all fields are identified with an unique ID.

second step:
create an trigger to verify if the element exist in database already. if select is returning null then then your current record is unique

best regards,

Re: preventing duplicate records from Delphi 80 80

What I meant is is there code I can use in Delphi to check and prevent this\
ie if "'+Combobox1.Text+'" exists
then
Button1,Enabled= False
or something like that, and yes there a Unique ID column

Thanks

Re: preventing duplicate records from Delphi 80 80

a solution would be to create a query, and to send the new field to it as a parameter. in query you must make a simple select statement. if query isn't returning nothing then your field is unique.

best regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.