将变量从C#传递到SSIS包 [英] Passing Variables from C# to SSIS package

查看:74
本文介绍了将变量从C#传递到SSIS包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在阅读这篇关于如何从C#代码执行SSIS包的文章,并发现它非常有用。

从C#执行SQL Server 2005 Integration Services包 [ ^ ]



我有一个类似的代码来调用我的SSIS包(一个CRM插件),它运行得很好。

但是我想从我的代码传递变量并在数据流任务的SQL命令中使用它们



我的代码中有以下逻辑来设置包的变量



变量vars = package2.Variables;

vars [开始 ] .Value = start;

vars [End]。值=结束;



我的包中有数据流任务根据日期参数检索数据。

那么,我如何在该数据流任务的SQL命令中使用这些Start和End变量。



请帮助。





谢谢

Hi,

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

推荐答案

查看此



如何执行SSIS来自.NET的软件包? [ ^ ]

将变量传递给SSIS的一些重要提示以编程方式打包 [ ^ ]

SSIS:读取和写入脚本任务中的变量 [ ^ ]

视频:Pt。 5 - 如何使用.NET传递变量并为SSIS包设置变量值 [ ^ ]
Check this

How to execute an SSIS package from .NET?[^]
Some important tips passing variables to SSIS package programmatically[^]
SSIS: Reading and Writing to Variables in Script Task[^]
Video: Pt. 5 - How to Pass In Variables and Set Variable Values for SSIS Packages Using .NET[^]






设置在包级别声明的变量值后,您可以在OLEDB源连接中使用此变量和数据流任务,您可以在其中定义查询,如下所示,并根据需要检索过滤后的数据你的参数。



例如



SELECT ID,OperatingDateKey,VehicleJourneyUID,OperatorID,JourneySequenceNo,AtcoCode,Lateness

FROM dbo.FactJourneyAdherence其中OperatingDateKey 之间?并且?



然后您可以在查询窗口旁边点击带有OLEDB源编辑器的参数按钮。



现在,您可以通过从下拉列表中选择变量值,将parameter0的变量值指定为startdate,将parameter1的变量值指定为enddate。





如果您有任何疑问,请告诉我。



问候,

Mubin
Hi,

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.

e.g.

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.

Regards,
Mubin

这篇关于将变量从C#传递到SSIS包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆