hi, i try this code:
function ConnectMySQL(iConexe: TZConnection; iIP: String; iDB : String): Boolean;
begin
Screen.Cursor := crSQLWait;
ConnectMySQL := False;
iConexe.HostName := iIP;
iConexe.Database := iDB;
try
iConexe.Connect;
ConnectMySQL := True;
except
on E:Exception do begin
showMessage('Cannot Conect' + Chr(10) + Chr(13) + E.Message);
end;
end; { except }
Screen.Cursor := crDefault;
end;
but if server is down, program crashes without any message
the same problem is when is missing libmysq.dll
any idea, what is wrong ?
thanx thom
how to handle exception if MySQL server does not respond ?
Moderators: gto, cipto_kh, EgonHugeist
i am sorry, its little weird, i create litle app with this try connect except block, and everything works fine, but in my big application shows exception only in Delphi IDE in runtime shows UNKNOWN exception should i setupo something in delphi menu tools - debug options - OS Exceptions ?
i'm using delphi 7 enterprise with SP1, Win XP x64 Sp2, XAMPP 1.6.7 with MySQL 5.0.51.
i'm using delphi 7 enterprise with SP1, Win XP x64 Sp2, XAMPP 1.6.7 with MySQL 5.0.51.
You do not have the required permissions to view the files attached to this post.
I usually use error string parsing. It works perfectly for my needs.
Code: Select all
except
on E: Exception do begin
Result:=false;
KnownError:=false;
if Pos('Access denied for user',E.Message)>0 then begin // Unknown user
KnownError:=true;
ErrMsg:='Wrong user';
end;
if Pos('Can''t connect to',E.Message)>0 then begin
KnownError:=true;
ErrMsg:='Unknown server';
end;
if Pos('Unknown database',E.Message)>0 then begin
KnownError:=true;
ErrMsg:='Unknown database';
end;
if not KnownError then
ErrMsg:=E.Message;
ShowMessage(ErrMsg);
end;
end;