Click here to Skip to main content
15,922,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I was reading this article on how to execute an SSIS package from C# code, and found it very useful.
Execute SQL Server 2005 Integration Services package from C#[^]

I have a similar code to invoke my SSIS package (a CRM Plugin), and it works perfectly.
But I want to pass variables from my code and use them in the Data Flow Task's SQL Command

I have the following logic in my code to set variables of the package

Variables vars = package2.Variables;
vars["Start"].Value = start;
vars["End"].Value = end;

I have a Data Flow Task in my package that retrieves data based on date parameters.
So, how do I use these Start and End variables in my SQL Command of that Data Flow task.

Please Help.

Thank you


After setting Variable values which are declared at package level , you can use this variables in your OLEDB Source Connection withing Data flow task where you can define your query such like this and retreive filtered data as per your parameters.


SELECT ID, OperatingDateKey, VehicleJourneyUID, OperatorID, JourneySequenceNo, AtcoCode, Lateness
FROM dbo.FactJourneyAdherence where OperatingDateKey between ? and ?

and then you can click on parameters button withing this OLEDB source editor just aside your query window.

now here you can specify variable value for parameter0 as startdate and variable value for parameter1 as enddate by selecting variable values from drop down.

Let me know if you have any query.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900