title: How to catch specific OleDbException?
body: <p>I need to catch the following specific exception:</p>
  
  <blockquote>
    <p>System.Data.OleDb.OleDbException was caught   ErrorCode=-2147467259<br>
    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"   StackTrace:
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult
    hr)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
    dbParams, Object&amp; executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp; executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
    behavior, Object&amp; executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
    behavior, String method)
           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()</p>
  </blockquote>
  
  <p>I'm not sure what <code>ErrorCode</code> is but it looks unreliable. </p>
  
  <p>Can I rely on <code>Message</code> being identical across platforms?</p>
  
  <p>Can I somehow use the <code>OleDbHResult hr</code> value found in the stack trace?  (See <a href="https://stackoverflow.com/a/991660/327528">https://stackoverflow.com/a/991660/327528</a>)</p>
  
  <p>Is the only solution to do a text search of <code>Message</code> for words like <code>duplicate</code> and <code>primary key</code>?</p>