Ron Schuster 0 Posted February 19 Is there a way to find out what driver (ODBC, SQL Native Client, etc. ) that FireDAC is actually using when establishing a connection to the MSSQL database? In the FireDAC connection all we get to specify is DriverID = MSSQL and FireDAC apparently chooses an appropriate driver based on what's available. Share this post Link to post
Dmitry Arefiev 105 Posted February 19 (edited) uses FireDAC.Phys.ODBCWrapper; procedure TForm252.Button1Click(Sender: TObject); begin ShowMessage(TODBCConnection(FDConnection1.CliObj).DRIVER_NAME); end; https://docwiki.embarcadero.com/Libraries/Athens/en/FireDAC.Comp.Client.TFDCustomConnection.CliObj Edited February 19 by Dmitry Arefiev 1 Share this post Link to post
Anders Melander 1795 Posted February 19 Seems like there's a bug in the documentation. Unfortunate. Quote // returns the ODBC driver DLL name for an ODBC-based connection ShowMessage(TODBCConnection(FDConnection1.CliObj).DRIVER.NAME); 1 Share this post Link to post
Lars Fosdal 1792 Posted February 20 @Ron Schuster You can explicitly control which driver you want to use. I use this code to pick my faves. class function TPSDFireDatabasePoolMSSQL.FindBestDriver(const Link: TFDPhysMSSQLDriverLink): String; const // Constants copied from implementation section of FireDAC.Phys.MSSQL C_SQL_SERVER = 'SQL Server'; // DO NOT TRANSLATE C_2019_ODBC = 'ODBC DRIVER 19 FOR SQL SERVER'; // DO NOT TRANSLATE C_2018_ODBC = 'ODBC DRIVER 18 FOR SQL SERVER'; // DO NOT TRANSLATE C_2017_ODBC = 'ODBC DRIVER 17 FOR SQL SERVER'; // DO NOT TRANSLATE C_2016_ODBC = 'ODBC DRIVER 13 FOR SQL SERVER'; // DO NOT TRANSLATE C_2012_ODBC = 'ODBC DRIVER 11 FOR SQL SERVER'; // DO NOT TRANSLATE {$IFDEF POSIX} C_FreeTDS = 'FreeTDS'; {$ENDIF} {$IFDEF MSWINDOWS} C_2012_NC = 'SQL SERVER NATIVE CLIENT 11.0'; // DO NOT TRANSLATE {$ENDIF} var DriverList : TStringList; WantedList : TArray<String>; Driver: string; begin Result := ''; // Blank = Default WantedList := {$IFDEF MSWINDOWS} {$IFDEF SQLNative} [C_2012_NC, C_2017_ODBC, C_2016_ODBC, C_2012_ODBC] {$ELSE} [C_2018_ODBC, C_2017_ODBC, C_2016_ODBC, C_2012_NC, C_2012_ODBC] {$ENDIF} {$ENDIF} {$IFDEF POSIX} [C_2018_ODBC, C_2017_ODBC, C_2016_ODBC, C_2012_ODBC, C_FreeTDS] {$ENDIF}; DriverList := TStringList.Create; try Link.GetDrivers(DriverList); DebugOut('Available SQL drivers'); // DO NOT TRANSLATE for Driver in DriverList do DebugOut(' "' + Driver + '"'); for var Wanted in WantedList do for Driver in DriverList do begin if CompareText(Wanted , Driver) = 0 then begin DebugOut('Selected driver: "' + Driver + '"'); // DO NOT TRANSLATE BestDriver := Driver; Exit(Driver); end; end; finally DriverList.Free; end; end; which I then use to configure the connections class function TPSDFireDatabasePoolMSSQL.CreateDriverLink(const aOwner: TComponent): TFDPhysDriverLink; var Res: TFDPhysMSSQLDriverLink; begin Res := TFDPhysMSSQLDriverLink.Create(aOwner); if BestDriver = '' then BestDriver := FindBestDriver(Res); Res.ODBCDriver := BestDriver; Result := Res; end; Share this post Link to post
Ron Schuster 0 Posted February 21 What would be the reason that I would want to assign a driver other than one FireDAC chooses by default? Share this post Link to post
Lars Fosdal 1792 Posted February 21 @Ron Schuster - Sometimes, there may be more than one driver installed, and the default one may be one that is less performant. Share this post Link to post