unique constraint

Posted on 2004-11-18
Last Modified: 2012-06-21
How do I catch a unique error constraint error on a try and catch block.....

say i want to trap a specific error like

if constraint_error then


end if
Question by:Moizsaif123
    LVL 6

    Accepted Solution

    i do it like this...

    catch ex as exception

    If Regex.IsMatch(ex.Message, "<ERROR MESSAGE TRAPPING FOR>") Then

    do this
    end if

    There may be a better way out there, but this has always met my needs
    LVL 6

    Expert Comment

           Dim constraint_error As Boolean = True
                If constraint_error Then Throw New Exception(constraint_error.ToString)
            Catch ex As Exception
                Response.Write("#" & ex.ToString & "#")
            End Try

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now