In your situation, the best course of action would be to test to see
if the inserted value would cause a duplicate *before* attempting the
insertion. You can then return the information in an output parameter
to the client application. This saves resources on the server. Here's
a sample of the logic you'd use:
-- If you get here, do the insert
On Wed, 29 May 2002 12:31:40 +0100, "john from herts"
>I have a stored procedure which I call from an ASP to insert records.
>insert a duplicate key.
>The transaction is rolled back, and in the ASP I get the return code I set
>in the SP, but the message
>Microsoft OLE DB Provider for ODBC Drivers error '80040e14' with the
>violation message still appears on the web page.
>How do I trap the error and then the return code to follow my own processing
>in the ASP ?