Error Code

R

rn5a

When a user finally confirms his order in a shopping cart application
(using MS-Access as the backend), the items he has purchased are
populated in a Access DB table named *Orders* & his personal details
(like name, e-mail, billing address, shipping address etc.) are
populated in another table named *CustDetails*. Both the DB tables
have a column named *OrderID*. This column is the Primary Key in the
*CustDetails* table & the Foreign Key in the *Orders* table. The
Session.SessionID becomes his unique OrderID.

After confirming an order, if the user refreshes the page, the app
will try to populate the same Session.SessionID in the *CustDetails*
table but since the column *OrderID* is a Primary Key column in the
table *CustDetails*, it won't accept duplicate OrderIDs. Under such
circumstances, an OleDbException will be raised.

Since a DB app can throw other OleDbExceptions other than the one
about which I mentioned above, I want to display custom error messages
to the user. For e.g. if he refreshes the page after confirming his
order, I want to display a message saying "Your order has already been
placed".

To do this, I tried using the *ErrorCode* property of the
OleDbException class but what I found is the *ErrorCode* changes from
time to time! Had a particular *ErrorCode* been assigned to the error,
I could have done something like this (assuming that the *ErrorCode*
for the above error is -12345 which is constant):

===================================
Try
'some code
Catch ex As OleDbException
If (ex.ErrorCode = -12345) Then
Response.Write("Your order has already been placed")
ElseIf (ex.ErrorCode = <some other constant ErrorCode>) Then
Response.Write("Another custom error message")
End If
End Try
===================================

But I can't do the above since the ErrorCode changes from time to
time.

So how do I display custom error messages to users under such
circumstances?

Of course, I can use the *Message* property of the OleDbException
class but that would be a rather tedious workaround.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top