Connection between MySQL and FireDAC closes the application when it is activated

0

I developed an application that uses FireDAC to connect to MySQL. But when I try to open it in a station, when the Connected := True is set, the application is closed, without returning any Exception. I wrapped the code in a try...except , but it still does not show any error messages. Here is the code I use for the connection

procedure TfrmServidor.confConnection;
begin
  with conMySQL do begin
    DriverName := LeXML.Strings[5];
    Params.Add('Server=' + LeXML.Strings[3]);
    Params.Add('Port=' + LeXML.Strings[4]);
    Params.Add('Database=' + LeXML.Strings[0]);
    Params.Add('User_Name=' + LeXML.Strings[1]);
    Params.Add('Password=' + LeXML.Strings[2]);
    ShowMessage(Params.Text);
  end;

  try
     conMySQL.Connected := True;
  except
     on e : Exception do
       ShowMessage(e.Message);
  end;
end;

Where LeXML is a function that reads an XML file with the connection properties and returns the values in a TStringList. what did I do wrong? The ShowMessage with Params.Text returns the following:

[Window Title]
Servidor

[Content]
DriverID=MySQL
Server=10.1.1.16
Port=3306
Database=treinamentos
User_Name=treinamentos
Password=masterkey


[OK]

Can anyone help me?

    
asked by anonymous 15.06.2015 / 16:32

2 answers

0

To fix the FireDAC connection problem with MySQL, just save the libmysql.dll and libmysqld.dll files in the workstation, either inside the folder with the application's executable or in the system's System32 folder. DLLs should be compatible with your MySQL version, so I suggest copying them from the LIB folder of the MySQL installation path.

    
15.06.2015 / 20:58
1

I went through the same situation with Firedac, your exception is wrong. Firedac only points to the error when you use the except below:

except on E: EFDDBEngineException do
  ShowMessage(E.message);

If you are using Firedac version 8.0.5.3365 change EFDDBEngineException to EADDBEngineException.

After finding the error code, it will be easy to solve it!

I hope I have contributed, good luck!

    
15.12.2015 / 15:22