469,602 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

error code -2147217873

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")?
Nov 19 '05 #1
2 3128
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.

"hansiman" <ha***@hotmail.com> wrote in message
news:jv********************************@4ax.com...
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")?

Nov 19 '05 #2
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.


On Tue, 12 Jul 2005 13:11:09 -0400, "Marina" <so*****@nospam.com>
wrote:
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.

"hansiman" <ha***@hotmail.com> wrote in message
news:jv********************************@4ax.com.. .
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")?


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tony Wright | last post: by
2 posts views Thread by Gregory | last post: by
6 posts views Thread by Peter Frost | last post: by
16 posts views Thread by Steve Jorgensen | last post: by
7 posts views Thread by p | last post: by
4 posts views Thread by Eugene Anthony | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.