Page 1 of 1
Dealing with connection errors
Posted: Fri 20 Jul 2018 17:45
by xxxFALKORxxx
Hi;
is there any piece of code where i can see how to deal with exceptions when i try to connect to server?
im using Delphi 7
TIA
Re: Dealing with connection errors
Posted: Mon 23 Jul 2018 08:23
by ViktorV
To solve your task, you can use the EMyError.ErrorCode property of
https://devart.com/mydac/docs/devart.da ... orcode.htm. You can find more information about the possible values of this property in MySQL server documentation:
https://dev.mysql.com/doc/refman/5.5/en ... erver.html and
https://dev.mysql.com/doc/refman/5.5/en ... lient.html
Code: Select all
try
MyConnection1.Connect;
except
on E: EMyError do
if EMyError(E).ErrorCode = 1045 then
ShowMessage('Access denied for user: ' + MyConnection1.Username)
else
raise;
end;
Note that to run this code, you should add the MyClasses unit to the USES clause of your unit.