Connection between Mysql and Firedac closes the application when enabled

Asked

Viewed 1,258 times

0

I have developed an application that uses Firedac to connect to Mysql. But when I try to open it on a station, at the time when the Connected := True, the application is closed, without returning any Exception. I wrapped the code in a try...except, but still shows no error message. 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 connection properties and returns the values in a Tstringlist.
What did I do wrong? The ShowMessage with the 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 someone help me?

2 answers

1

I went through the same situation with Firedac, your Exception is wrong. Firedac only points error when you use 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 discovering the error code it will be easy to fix it!

I hope I contributed, good luck!

0


To fix Firedac connection problem with Mysql, just save the files on the station libmysql.dll and libmysqld.dll, or inside the folder with the application executable or inside the system’s System32 folder. Dlls must be compatible with your Mysql version, so I suggest copying them from the LIB folder of the Mysql installation path.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.