Console FireDAC Example wanted

Console FireDAC Example wanted

Doing FireDAC againt MSSQL or PostgreSQL visually is easy, but when I try to do it in code only – I get weird errors and there must be something essential that I miss.

Does anyone have a code only example of how to set up a FireDAC connection?

 

20 thoughts on “Console FireDAC Example wanted


  1. I had problems if I did not add tons of stuff into the Uses Clause,  drivers and so… They just need to be some where, and if in Console most likely not some is missing…


  2. I set these params on the BeforeOpen, see if it helps :


         myDatabase.Params.Values[‘Password’] := ‘***’;


         myDatabase.Params.Values[‘User_Name’] := ‘postgres’;


         myDatabase.Params.Values[‘Database’] := ‘mydatabasename’;


         myDatabase.Params.Values[‘Port’] := ‘5432’;


         myDatabase.Params.Values[‘Server’] := ‘127.0.0.1’;


    Besides, I have no problems with FD and PG.


  3. function TFDAdaptedDataSet.GetOptionsIntf: IFDStanOptions;


    begin


      Result := Command.OptionsIntf;


    AV because Command is nil


    Stack:


    FireDAC.Comp.Client.TFDAdaptedDataSet.GetOptionsIntf


    FireDAC.Comp.DataSet.TFDDataSet.GetResourceOptions


    FireDAC.Comp.DataSet.TFDDataSet.StartWait


    FireDAC.Comp.DataSet.TFDDataSet.OpenCursor(False)


    Data.DB.TDataSet.SetActive(???)


  4. Magno Lima 


            FConnection.Params.Add(‘DriverId=MSSQL’);


            FConnection.Params.Add(‘Server=’+Trim(FHost));


            FConnection.Params.Add(‘Database=’+Trim(FDatabaseName));


            FConnection.Params.Add(‘OSAuthent=No’);


            FConnection.Params.Add(‘User_Name=’+Trim(FUserName));


            FConnection.Params.Add(‘Password=’+Trim(FPassword));


  5. For example MSSQL:


    1. Create a TFDPhysMSSQLDriverLink instance


    2. Create a TFDConnection and set the params


    3. Create a TFDQuery and set the connection


    The driver link has to be created only once for the application, while the connection has to be separate for each connection(obviously) and for each thread. Make sure to say “uses uFDGUIxConsoleWait” somewhere. 


  6. Uwe Raabe 


    1. Check – Single instance


    2. Check – One instance per target server


    3. Check


    uFDGUIxConsoleWait is named FireDAC.ConsoleUI.Wait in XE6 and XE7.  Does it matter if it is included in a GUI app as well?


    Still same problem.


  7. Please set a break point on


    unit FireDAC.Comp.Client;


    function TFDAdaptedDataSet.GetCommand: TFDCustomCommand;   //BP here


    begin


      if Adapter nil then


        Result := Adapter.SelectCommand   // you lack of SelectCommand?


      else


        Result := nil;


    end;


    if AV cause by Command is nil.


  8. Sam Shaw Adapter is assigned.


    The actual code is a rewrite of ADO code, and I am starting to suspect that I am doing some silly ADOism where I should be doing things differently and the FireDAC way.


  9. Lars Fosdal yes it works, but as it is a string list will add new line and by default using the last one… Maybe someone told but dont forget using TWaitCursor. When creating FD connection for postgres in runtime I dont mess with any other parameter but that I told first. I am using XE5.

Leave a Reply to Lars FosdalCancel reply