How to detect the latest ODBC driver installed on the target machine

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

The AI_DETECTED_SQLSERVER_ODBCDRIVER_VERSION predefined property resolves to the version of the latest ODBC driver available on the target machine.

To get the name of the newest ODBC driver installed on the target machine you can set your own custom property (e.g. LATEST_ODBC_DRIVER_PROP) to the name of the ODBC driver depending on the version the AI_DETECTED_SQLSERVER_ODBCDRIVER_VERSION property is set to.

To achieve this, you can proceed like this:

  • 1. Go to Properties page and define the LATEST_ODBC_DRIVER_PROP property like this: Name:LATEST_ODBC_DRIVER_PROP, Value: SQL Server
  • 2. Go to Custom Actions page and add three "Set installer property" custom actions, scheduled after "Install Execution Stage -> Searches" action group, configured like this:

Property:LATEST_ODBC_DRIVER_PROP, Value: {SQL Driver 11 for SQL Server}, Condition:AI_DETECTED_SQLSERVER_ODBCDRIVER_VERSION = "11.0"

Property:LATEST_ODBC_DRIVER_PROP, Value: {SQL Driver 13 for SQL Server}, Condition:AI_DETECTED_SQLSERVER_ODBCDRIVER_VERSION = "13.0"

Property:LATEST_ODBC_DRIVER_PROP, Value: {SQL Driver 17 for SQL Server}, Condition:AI_DETECTED_SQLSERVER_ODBCDRIVER_VERSION = "17.0"

  • Select, in turn, each of the above set property custom action and while keeping the SHIFT key pressed drag and drop it under "Wizard Dialogs Stage -> Searches" action group (this way the actions will be shared between both installation execution stages).