将 User::variable 传递给自定义 ssis 任务
我正在开发一个自定义 SSIS 任务。它公开了一些由用户定义的属性。目前我还没有实现 GUI,所以我在任务属性窗口中设置参数。
现在假设我有一个名为 LastName 的属性,并且有一个 SSIS 变量 User::LastName。 当我将 User::LastName 放入属性中时,它只是传递字符串:“User::LastName”,而不是评估字符串的值......
我怎样才能让它传递字符串的值?
I am developing a custom SSIS task. It exposes a few properties which are to be defined by the user. For now I have not implemented the GUI so I set the parameters in the task properties window.
Now say I have a property called LastName, and I have an SSIS Variable User::LastName.
When I put User::LastName into the properties, it just passes the string: "User::LastName" instead of evaluating the value of the string....
How can I have it pass the value of the string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您确定这一点时,您已将变量的名称传递给组件。您将需要评估 Dts.Variables 集合中对象的值,并将其转换为适当的类型。
我认为您正在考虑在组件中使用两个变量,一个用于来回传递变量名称,另一个用于保存实际值。您可能可以创建一个处理这两个问题的结构,但我愿意在答案中徒手绘制它;)
As you've determined st that point, you've passed in the name of the variable to the component. You will need to evaluate the value of the object in the Dts.Variables collection, cast to the appropriate type.
I think you're looking at either having two variables in your component, one to pass the variable name back and forth and one to hold the actual value. You could probably make a struct that handles both of those but I'm willing to freehand that in an answer ;)
我找到了解决办法。
在包中定义变量 LastName,并给它一个值,例如“John”。然后在自定义任务属性中,单击“表达式”,然后单击“[...]”。在属性下选择 LastName 属性(或自定义任务中定义的任何名称),然后在表达式下单击 [...]。通过展开变量,您可以获得所有变量的列表。然后,您可以将所需的变量拖放到下面的表达式输入框中。评估表达式按钮可以验证它是否包含所需的值。然后单击“确定”和“确定”...构建 SSIS 项目然后就可以了...
I have found a solution.
Define the variable LastName in the package given it a value, say "John". Then in the custom task properties, click on Expressions, and click on the [...]. There under property select LastName property (or whatever name is defined in the custom tasks) and then under experssion click on [...]. By expanding Variables you get a list of all your variables. You can then drag drop a wanted variable into the Expression input box under. Evaluate expression button enables to verify it contains the wanted value. Then click OK and OK... Building the SSIS project then does the trick...