error code -2147217873

H

hansiman

I'm wondering how best to present exception messages to a user.

In a try catch I catch an OleDb.OleDbException. The error could be a
COLUMN REFERENCE constraint error (by a deletion attempt).

The normal user would not know what to make of the standard error
message (exOleDb.Message) and I'm not sure how best to use the the
exOleDb.ErrorCode (-2147217873)?

Is best practise to present the user to a general message like "An SQL
Server Error Occurred: " and include the exOleDb.Message? or is it
better to search the exOleDb.Message for key words and then present
the user with an understandable error message ("you can't delete x
because x is used somewhere else, bla bla bla")?
 
M

Marina

There should be a documented list of error codes, and you should catch the
most common ones and display the appropriate message. It's not always useful
for the user to know there was an error. In this case the user can attempt
to delete the record and get the same message each time. But if the message
said why there was an error - that becomes useful information, and the user
won't sit there trying to delete the record.

An even better approach would be for you to manually check the database to
see if the record in question is referenced in any other tables before even
trying to issue the users's delete request. That way you avoid exceptions
altogether, and can have a nice meaningful message.
 
H

hansiman

Thanks.

I think I'll go for the solution that first checks if the id is used
before I attempting to delete the row.

I can't find the error message for error code 2147217873 anywhere on
either on google, ms or in sql bol.
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top