• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

unique constraint

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

' DO THIS

end if
0
Moizsaif123
Asked:
Moizsaif123
1 Solution
 
slyckboyCommented:
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
0
 
platinumbayCommented:
       Dim constraint_error As Boolean = True
        Try
            If constraint_error Then Throw New Exception(constraint_error.ToString)
        Catch ex As Exception
            Response.Write("#" & ex.ToString & "#")
        End Try
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now