I try to catch/get the Type of the OleDbException
to generate the correct error message.
At this moment I'm sure I catch whatever OleDbException, but I want to catch only duplicate value violations to generate the error message.
This is what I do for the moment.
ex As OleDb.OleDbException
MessageBox.Show(ex.Errors.Item(1).ToString(), "Error Message", MessageBoxButtons.OK)
The output is like:
"Violation of UNIQUE KEY constraint 'UC_MyTable'. Cannot insert duplicate key in object 'dbo.MyTable'. The duplicate key value is (PJO, Peter Johanson)."