myConnetion Test

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Thr33D
Posts: 2
Joined: Mon 18 Apr 2011 13:28
Contact:

myConnetion Test

Post by Thr33D » Mon 18 Apr 2011 14:47

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.

AndreyZ

Post by AndreyZ » Tue 19 Apr 2011 08:49

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.

Post Reply