简体   繁体   中英

Connect FireDAC to SQL Server through ODBC Driver 17 instead of SQL Server Native Client

I want to connect my FireDAC application using the latest Microsoft ODBC Driver for SQL Server 17, but my connection always uses the SQL Server Native Client 11 driver.

This is the code I tried to indicate the desired driver:

FireDriverLink := TFDPhysMSSQLDriverLink.Create(nil);
FireDriverLink.ODBCDriver := 'ODBC Driver 17 for SQL Server';
FDConnection.DriverName := FireDriverLink.BaseDriverId;

To check the driver used, I raise an exception and read the error message:

FDConnection.ExecSQL('select convert(integer, ''X'')');

[FireDAC][Phys][ODBC][Microsoft] [SQL Server Native Client 11.0] [SQL Server]Error de conversión al convertir el valor varchar 'X' al tipo de datos int.

How is the correct way to tell FireDAC to use the ODBC Driver for SQL Server 17 ?. Also, could I also tell FireDAC to use the latest ODBC Driver at design time instead of the native client ?.

Thank you.

For design time: drop a TFDPhysMSSQLDriverLink on the data module or form and set the ODBC driver to: ODBC Driver 17 for SQL Server in the drop down.

After that open your TFDConnection and switch to the Info tab and check what driver it ends up using along with any notes it mentions.

Note from the OP: To work for me I've needed to give a name to the TFDPhysMSSQLDriverLink component on its DriverID property, and set that name to the DriverName property of the TFDConnection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM