This topic is locked

How to prevent duplicates?

3/19/2008 1:58:53 PM
ASPRunnerPro General questions
D
dunga author

is there a special code so that I can prevent people from entering duplicates?
for example I have employeeID field which must be filled upon data entry, however, 2 departments are entering same database, and sometimes enter duplicate employeeID,
how can I I prevent that???
thanks

J
Jane 3/21/2008

Hi,
you can check entered value in the Before record added event and print error message if entered value exists in the database.

D
dunga author 3/21/2008

hi,Jane, could you explain in detail?

what lines to add, where to add?
thank you

J
Jane 3/24/2008

Hi,
here is a sample:

str = "select count(FieldName) as cFieldName from TableName where FieldName='" & dict("FieldName") & "'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
if rsTemp(0)<>0 then

Response.Write "error!"

BeforeEdit = False

else

BeforeEdit = True

end if
rsTemp.Close : set rsTemp = Nothing

J
justicejayant x 3/27/2008

Hi,

here is a sample:


Thanks