我在SSIS中有一个C#脚本任务,我可以将一个变量传递给没有问题。我在脚本中创建了另一个类,调用otherclass.cs。如何在其他class.cs中使用变量?除了ScriptMain.cs之外,在另一个类中使用SSIS变量
我想只是这样做:
_urlBase = Dts.Variables["User::URLBase"].Value.ToString();
但我得到这个错误:
The name 'Dts' does not exist in the current context
我很新的C#和类,所以我可能无法正确问这个问题。我甚至可能问什么?
谢谢。
SOLUTION
这里是我的解决方案是什么,我试图做到:
在ScriptMain.cs创建这样的新服务:
OtherService ws = new OtherService(Dts.Variables["User::URLBase"].Value.ToString());
在OtherService.cs我有这个:
class OtherService
{
public OtherService(string urlBase)
{
_urlBase = urlBase;
//do other stuff
}
//other methods and stuff
}
为什么不把dts变量的值传递给构造函数或方法中的'Otherclass'? – cfrag 2012-03-20 13:36:18