SSIS how to set connection string dynamically from a config file

First add a variable to your SSIS package (Package Scope) – I used FileName, OleRootFilePath, OleProperties, OleProvider. The type for each variable is “string”. Then I create a Configuration file (Select each variable – value) – populate the values in the configuration file – Eg: for OleProperties – Microsoft.ACE.OLEDB.12.0; for OleProperties – Excel 8.0;HDR=, OleRootFilePath – Your Excel file path, FileName – FileName

In the Connection manager – I then set the Properties-> Expressions-> Connection string expression dynamically eg:

"Provider=" + @[User::OleProvider] + "Data Source=" + @[User::OleRootFilePath]
+ @[User::FileName]  + ";Extended Properties=\"" + @[User::OleProperties] + "NO \""+";"

This way once you set the variables values and change it in your configuration file – the connection string will change dynamically – this helps especially in moving from development to production environments.

Leave a Comment