Reputation: 69524
I have had Packages in the past where I was looping through multiple Text files in a folder and loading into sql server tables.
Now I am asked to create a package which will loop through Multiple Excel Files in a folder and load them into sql server table.
I went through the following steps to create this package assuming it shouldn't be much different from what I have in other packages where it loops through multiple Flat file.
Added an Execute Sql Task
, Truncating my staging table, A simple Truncate table statement.
Added a Foreach Loop Container
. Selected Foreach File Enumerator
and created a variable called File_Path
with data type string.
Added a Data Flow Task
.
Added an Excel Data Source
. and configured the Excel Connection manager
By selecting any one 'Excel' File in the destination folder. (At this point is configured correctly as it is not showing any red cross or warring messages.)
Then I selected the Excel File Connection Manager
and in Properties
windows Under Expressions
, Selected Connection String
property and Used the User Variable @User::File_Path
.
At this point the Excel Data source is showing a Red Cross
as it needs further configuration.
I have tried a few things Like changing the Data Access Mode
from Table name
to Table Name or View Name Variable
, And passing variable @User::File_Path
but it gives me the following error.
Can someone please have a look and advice where I am going wrong and how I can fix this? Any Advice or a pointer in the right direction is much appreciated.
Thank you.
Upvotes: 1
Views: 2817
Reputation: 1913
You shouldn't use an expression on the ConnectionString property, but on the ExcelFilePath property.
Upvotes: 1