FireDAC WTF of the day ;)

FireDAC WTF of the day 😉

Conn := TFDConnection.Create(nil);

Conn.DriverName := FireDriverLink.BaseDriverId;

// The above lines were actually in a function in the worker pool

for tgt in targetlist

do begin

  Conn.Params.Clear;

  Conn.Params.Values[‘Server’] := tgt.Host;

  Conn.Params.Values[‘Database’] := tgt.DatabaseName;

  Conn.Params.Values[‘OSAuthent’] := ‘No’;

  Conn.Params.Values[‘User_Name’] := tgt.UserName;

  Conn.Params.Values[‘Password’] := tgt.Password;

  Conn.Connect;

  Exception: Driver name not set.

I added the above clear since I would be reusing the connection for multiple databases in a loop, and it took me a few rounds in the debugger before I figured out that the property mapped into the params list instead of a property field of it’s own.

Lesson learned.

7 thoughts on “FireDAC WTF of the day ;)


  1. From AnyDAC documentation:


    with ADConnection1.Params do begin


      Clear;


      Add(‘DriverID=Ora’);


      Add(‘Database=ORA_920_APP’);


      Add(‘User_Name=ADDemo’);


      Add(‘Password=a’);


    end;


    ADConnection1.Connected := True;


  2. Fabio VITALE The issue is that the DriverName on the connection class actually sets a parameter, so when you call Params.Clear you remove the driver name as well.


  3. Fabio VITALE – The FireDAC documentation is largely oriented towards using the components by dropping them on a form, rather than setting things up in source code.  It is possible that it is documented somewhere that the “DriverName” property is mapped into the Params list, but I failed to spot that piece of information.  


  4. They definitely need more documentation on this. Anyone with a test and production environment which I assume is almost everyone needs to change these parameters at run time.

Leave a Reply