Re: How to identify an error?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: One Handed Man \( OHM#\) ("One)
Date: 06/10/04


Date: Thu, 10 Jun 2004 09:51:19 +0100

One way around this is to set the column seed to -1 and count down. This way
when the new records are inserted you will not get duplicates assuming your
records are all positive.

However, I would recommend that if possible you dump this idea and use
GUID's which are extremely reliable as far a uniqueness is concerned ( not
totally though ).

Regards - OHM

"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:OlPwtMsTEHA.2464@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I want my application do different actions depending on the exception it
> gets.
> For exemple: I have an SQL-table with a unique index. In case I try to
> Insert a record that's alreaddy in it I get this exception: "Cannot insert
> duplicate key row in object 'tblTelephones' with unique index
> 'UniqueValues'."
>
> What I'm looking for is a way to identify the exception: in case I get
this
> exception I want to do this, in case of another I want to do that.
>
> The most simple solution to me seems this:
> Catch ex As Exception
> If Left(ex.Message, 41) <> "Cannot insert duplicate key row in
> object" Then
> 'do this action
> End If
>
> QAlthough, I'm not convinced this is the best way. Is there a way to
> identify the exception with a unique number? Or I've seen once something
> like a name for an error. Can anybody help me with this?
>
> Thanks a lot in advance
>
> Pieter
>
>
>



Relevant Pages

  • Re: Catch "Cannot insert duplicate key row" exception
    ... Is an "Cannot insert duplicate key row" exception from a FormView ... If you have some kind of problem with inserting records into a SQL Server table based on a table's primary record-key, you got other problems out the gate that you should be dealing with, because this kind of error condition should net be happening if the code is solid. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to identify an error?
    ... Regards - OHM ... > I want my application do different actions depending on the exception it ... > duplicate key row in object 'tblTelephones' with unique index ...
    (microsoft.public.dotnet.framework)
  • Re: How to identify an error?
    ... Regards - OHM ... > I want my application do different actions depending on the exception it ... > duplicate key row in object 'tblTelephones' with unique index ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: How to identify an error?
    ... Regards - OHM ... > I want my application do different actions depending on the exception it ... > duplicate key row in object 'tblTelephones' with unique index ...
    (microsoft.public.dotnet.languages.vb)
  • Catch "Cannot insert duplicate key row" exception
    ... appology for the 2 part question. ... Is an "Cannot insert duplicate key row" exception from a FormView ... returned as part of the ItemInserting or ItemInserted event? ...
    (microsoft.public.dotnet.languages.csharp)