Catching Specific Exception question...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
How would I catch a specific exception? For instance I have a table with a compound primary key... the primary key is not an auto increment but I dont want to allow duplicates to be inserted. When I try to insert a duplicate it throws an exception, naturally. I am able to trap the SQLException but I'm not sure how to catch that specific 'Violation of PRIMARY KEY constraint'...



Should I query the table before I attempt the insert instead of trying to catch the exception?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search