Here is a place to start:
When you trap an exception:
try
{
Do Something With Ole Db and Access;
}
catch(OleDbException ex)
{
MessageBox.Show(this, ex.Message);
}
catch(Exception ex)
{
MessageBox.Show(this, ex.Message);
}
If you want the user to see what the error description is the Message
Property of the Exception object will usually contain a friendly
description of the error.
The Exception object contains a lot of other stuff you can use to find
out what happened and where. Check the Exception object out in the
Help files to see more...
There is a Microsoft publication, "Jet Database Engine Programmer's
Guide" that has a table of error numbers and their corresponding
descriptions, but the book targets DAO instead of ADO.NET and does not
use the same error numbers you will see in ADO.NET errors. However if
you can get a copy of it (it may not be in print any more) it's worth
having, because it can help you understand how Jet works behind the
scenes. In addition there are things you can do in DAO that you can't
do with ADO.NET, like building an Access DB straight from code, and
all you have to do is reference the DAO library in your using
statements and add it as a reference in your project. VS 2003 will
put it in a wrapper for you.
Sorry for being so long winded...
Does anyone know the name of the exception that is thrown
when an attempt is made to add a duplicate entry (key
value) to an Access data base?
The int value appears to be -2147467259.
Any one know where I can find a list of exceptions and
their corresponding integer value?
Thanks
Otis Mukinfus
http://www.otismukinfus.com