: : I don't know the answer to your first question, but I do to the second question. You have to look to the message to distinguish the various errors. Here is a code, which shows the message to the user as an example:
: :
: : try
: : // DataBase Statements
: : except
: : on E: EDataBaseError do
: : ShowMessage(E.Message);
: : end;
: :
: : By parsing the message, you can distinguish between the various errors.
: :
: I thought about it, but isn't it so that the message returned will depend on operating system? If the program is installed on localized version of Windows (say, Swedish or Russian), will the message still be on English? If not, my code for identifying errors based on messages, won't work.
:
That I don't know. I think it depends if the DBE is localized. I don't have much experience with using the DBE components. In some messages I've seen a hex value or an ErrorCode field, which identifies the error type and should be the same for all languages. Here is an example I came across during a google search:
try
SomeCodeThatRaisesAnEConvertError;
except
on E: EIBError do begin
if E.ErrorCode = iSomeCodeIWantToCatch then
begin
// Deal with this specific exception here
end else
begin
raise; // re-raise the exception if its not the one I handle
end;
end;
end;
Source: http://community.borland.com/article/0,1410,32156,0.html
But this won't work with the general EDatabaseError.
You might find more info in the manual of the DB engine you are designing your program to use.