Visual Basic .NET » ASP.NET General Discussion
Violation of PRIMARY KEY constraint 'PK Employee'. Cannot insert duplicate key in object 'dbo.Emp'. The statement has been terminated -- raibeart --


You are trying to add a record for EmpID that already exists.

Simply make it a integer indentity data type. Then if you have an employee number that you want to store, save that in a different column, i.e. EmpNbr. If you want it to be unique, put a unique index on it.

It the user can enter the EmbNbr, then do a check to see if it exists BEFORE trying to insert the record.

If it is already an integer identity, DO NOT try to insert a value into it.

[Submit Comment]Home