SSIS Dynamically Import Excel Files

0

So I created a ForEach loop and a data flow task to write from Excel to SQL DB. All works fine with the Excel source hard coded. As soon as I change the connection string to use the file path variable as a data source, I get this error:

[Excel Source 1] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager 1" failed with error code 0xC0202009.

I print the file path in a message box before executing the data flow so I know that the variable is working.

enter image description here

enter image description here

Naturally I browsed tons of answers and tutorials, but nothing. Here's what I tried:

  • Changing the data source on the connection string
  • Using the ExcelFilePath expression instead of the connection string
  • Changing the Excel file name in the connection manager properties
  • Ran the package in 32 bits
  • Set delayed validation to True in all data flow tasks and connection manager
  • Deleting and creating a new connection manager
  • Combinations of the above, lots of trial an error

I'm using Visual Studio 2013.

I'd appreciate your help as I've been plucking my hair all afternoon with this :)

excel
ssis
sql-server-data-tools
asked on Stack Overflow Jun 6, 2018 by MrM1k4d0 • edited Jun 7, 2018 by MrM1k4d0

1 Answer

0

I never got this to work, so I imported the Excel files to the DB using SQL:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Test\Excel_Data.xlsx;', 'SELECT * FROM [Sheet1$]')

https://www.sqlshack.com/query-excel-data-using-sql-server-linked-servers/

answered on Stack Overflow Aug 9, 2018 by MrM1k4d0

User contributions licensed under CC BY-SA 3.0