Traping SQL returning errors

  • How can i prevent a ADO application (Client side) to not recieve errors from SQL sever

    for example i use a procedure for inserting but the user dont care for duplicate values

    SQL server return a uniqe violation for the Index Its easy to do it on the client side but on the server side i always haves the message ????

  • Check if the key exists before inserting.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • in other words :

    INSERT INTO TABLE(x1,,...) VALUES (@x1,@x2,...)

    WHERE TABLE.PRIMARY_KEY <> @YOUR_PRIMARY_KEY

    Edited by - noeld on 12/16/2003 06:57:22 AM


    * Noel

  • try using an *exception handler* on client side ...

    best regards,

    chris.

  • You can try to do something like this:

    If exists(select * from table where key = @key)

    insert into table (key,...)

    values (@key,...)

    else

    return -1

  • quote:


    You can try to do something like this:

    If exists(select * from table where key = @key)

    insert into table (key,...)

    values (@key,...)

    else

    return -1


    in a highly transactional enviroment a connection could insert the @id that the exists query is checking AFTER the check and BEFORE the insert. That's why you should NOT splitt the query into several if you are not using explicit Transactions!!!


    * Noel

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply