myConnetion Test
myConnetion Test
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
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: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.
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;