Page 1 of 1

myConnetion Test

Posted: Mon 18 Apr 2011 14:47
by Thr33D
Is it possible to check the connection to MySQL-Database with MyConnection before MyConnection.connected := true. If there no connection to the database to show a message box (showmessage) but no error message.

Posted: Tue 19 Apr 2011 08:49
by AndreyZ
Hello,

The only way to check if it's possibile to connect to a MySQL server is to perform a connection attempt. You can use the following code to avoid the error message:

Code: Select all

try
  MyConnection.Open;
except
  ShowMessage('Connection failed');
end;
Note that if you run your application from IDE, you will see the error message, but if you run the executable file, there will be only the 'Connection failed' message.