May 27, 2009 at 9:52 pm
What are the steps necessary to pass the Excel Source the excel file name as a variable? I've tried this a few different ways now and have had issues each way.
I've been trying to get this working for days! I've read a couple of long threads that involve a ForEach Loop Container to get multiple excel files and I've stepped thru them and am still stuck. I only wish to load one file per run. The format and location of the Excel File will never change - just the file name.
Here's what I've tried most recently:
1. Create Variable
Variable Name: FileName
Scope: Package
Data Type: String
Value: F:\apps\excel\Expense_Report_Form.xls
2. Run Package Nomally (w/o variable)
Excel Source: I set this up to point to the Excel File and tested with the Data Conversion and OLE DB Destination. Execute the package and it runs as expected. Moves Excel data to SQL Server.
3. Create expression (Connection Manager)
In the connection manager for the excel source create a expression
Property: ConnectionString
Expression: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @[User::FileName] +";Extended Properties=\"Excel 8.0;HDR=YES\";"
When I click evaluate expression it returns the following:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\apps\excel\Expense_Report_Form.xls;Extended Properties="Excel 8.0;HDR=YES";
As soon as I setup the expression the excel source gets a red X with error "an OLE DB error has occurred." If I try and execute the package it fails at that step. What am I missing here?? Right now I have delay validation set to "false" on the connection manager properties.
I am beyond frustrated at this point. I would greatly appreciate any advice you have to offer. Thanks in advance:-)
May 27, 2009 at 10:24 pm
Delay validation should be set to True, not False, if the source file does not exist until run-time.
You could approach this a different way. Set up a hard-coded connection to, say, Data.xls and as the first part in your package, copy the dynamically named Excel file to it, overwriting what is already there.
Then allow the process to run using data.xls, which will always exist and your validation problems should go away.
Phil
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
May 27, 2009 at 11:24 pm
Thanks for the reply Phil! I completely rebuilt the package, set delay validation = false..and it runs without error!
One more question. I'm trying to execute the package from a SP. What's the proper syntax to pass the variable from the SP to the SSIS package? My overall goal is to call the SSIS package programatically from an asp.net application. So I'll be passing the filename as a varaible from the program.
Here's what I have so far:
AS
DECLARE @cmd varchar(1000)
DECLARE @SSISpath varchar(1000)
DECLARE @ReturnCode int
set @SSISpath = 'F:\apps\SSIS Packages\ExcelImport.dtsx'
set @cmd= 'dtexec /F "' + @SSISpath + '"'
set @cmd = @cmd + ' /SET \Package.Variables[User::FileName].Properties[Value];"'
EXEC @ReturnCode = master..xp_cmdshell @cmd
Again, thanks for all your help!
November 8, 2012 at 4:31 pm
Hi I have same problem, I could not follow you could you please explan little more detail what to do.
It would be really great help, I spend, 5 hrs on this. In .cvs works perfect
November 9, 2012 at 12:30 am
Munabhai (11/8/2012)
Hi I have same problem, I could not follow you could you please explan little more detail what to do.It would be really great help, I spend, 5 hrs on this. In .cvs works perfect
What's the issue? Any errors?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply