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
Dealing with connection errors
Re: Dealing with connection errors
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
Note that to run this code, you should add the MyClasses unit to the USES clause of your unit.
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;