I have an app that uses OleDB to connect to an Access database. I am trying to create some error handling for inserting duplicate records, where there is a unique index.
When this error is thrown I get the error code -2147467259 on the exception. However other errors also give the same error code; Database full, or column missing for example.
Is there a way to determine between these different errors without using the error message itself which every part of me says will be unreliable.
I have looked at .innerexception
, in the case of inserting duplicates there is no inner exception.
I have also looked at .SQLState property, it appears that this is an old method not really within use in the 4.0 framework. I could apply this but I would likely be using on error, rather than my desired try catch.
My code at the moment:
Try
Sender.cmdOLEDB.ExecuteNonQuery()
Catch ex As OleDbException
End Try