How to catch specific exception without error number?
- by CJ7
I need to catch the following specific exception:
System.Data.OleDb.OleDbException was caught
ErrorCode=-2147467259
Message="The changes you requested to the table were not successful
because they would create duplicate values in the index, primary key,
or relationship. Change the data in the field or fields that contain
duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again."
Source="Microsoft JET Database Engine"
I'm not sure what ErrorCode is but it looks unreliable. Can I rely on Message being identical across platforms? Is the only solution to do a text search of Message for words like duplicate and primary key?
Note: see my question here for why I need to catch this exception.