Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

asp.net custom exception handling

user10427840Aug 27 2010
Hello all,

I have an object-relational database. I have it accessed from a web interface. This is pretty tough to deal with in asp.net. For inserting new data, I put textboxes and a button on a separate page. Data is inserted on the button_click event. Works perfectly. However, whenever a duplicate key is entered, I get the ORA-00001: unique constraint violated error. I would like to create my own error message(label, messagebox, response.redirect, whatever works best). The code below is what I've come up with. I managed to get it to redirect to my error page if there was an error. But I'm trying to get it to work for that specific error. I've tried statements as "ElseIf (ex.Message.Contains("ORA-00001")) Then" but they don't work. How do I get it to work for a specific error code? I originally posted this in the ASP.NET forum here and was directed here.

Try

aCommand.Connection.Open()

Catch ex As OleDbException

If e.Exception Is Nothing Then
MsgBox("Information entered", 0, "Success!!")
Else
Response.Redirect("errorpage.aspx")

End If

End Try

My INSERT statement is:

insert into branch values(:branch_id, location_type(:street, :city, :state, :zip), staff_nested())

Thanks in advance for your time.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2010
Added on Aug 27 2010
0 comments
993 views