I got stuck with SSIS. When I try to use a foreach container to loop through one recordset I extract from an Excel file.
Here are two variables I used:
The first thing I do is to extract data from an Excel file, then store it into variable "CriteriaResult" as a recordset.
Then in the foreach loop, I use an ADO Enumerator to access this recordset:
Each record in this recordset will be converted to a string variable "CriteriaID":
Then I will insert this record to a table in SQL Server:
The parameter setting is the same as the column's data type in the SQL Server table:
However, I got an error at the foreach loop step:
Error: 0xC001F009 at Get excel data: The type of the value being assigned to variable "User::CriteriaID" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
The raw data in the Excel file is like this:
It starts with number 1 and 2, then change to 3A, 3B.... I guess that's why it claims the data type changes at a foreach loop step. Could I add any script task to format data within the recordset before looping through it?
The other potential issue could come from the merging cells. However, I tried a single cell before, and it works well.
How can I fix this problem?









