Home » excel » sql server – How to pass the excel connection string dynamically in the foreach loop container for Excel Source?

sql server – How to pass the excel connection string dynamically in the foreach loop container for Excel Source?

Posted by: admin May 14, 2020 Leave a comment

Questions:

How to pass the excel connection string dynamically in the foreach loop container for Excel Source?

In the Foreach Loop Container, I have the variable set to the Expressions / Directory.

In the Excel Source, I have mapped the Excel Connection String with the same variable mentioned in the Foreach loop Container.

However, I am getting an error

This error is thrown by Connections collection when the specific connection element is not found

enter image description here

How to&Answers:

You can perform this in 3 steps:

  1. In the for each loop container, go to Variable Mappings and Map the result of the loop into a variable.
  2. On the Excel Connection Manager, Go to expressions, Set the value of ExcelFilePath property expression to the variable you created in the for each loop.
  3. On the dataflow task Change the Delay Validation property value to True.

For a detailed step-by-step tutorials, check the following links:

<a href="https://exceptionshub.com/category/sql-server”>More Answers>