如何将脚本任务(c#)中的变量值传递给包中​​的变量 [英] How to pass a variable value from a Script task (c#) to a variable in the package

查看:67
本文介绍了如何将脚本任务(c#)中的变量值传递给包中​​的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

非常感谢您的帮助。

我在SSIS包中进行一些交互。我在脚本任务中有一个C#代码,我发出一个消息框询问是或否。如果是,则C#代码中定义的变量得到值0否则得到1.我需要将该值传递给包中定义的变量
继续流程。

I am giving some interaction in a SSIS package. I have a C# code in a script task where I issue a message box to ask for Yes or No. If it is yes a variable defined in the C# code gets the value 0 otherwise it gets 1. I need to pass that value to a variable defined in the package to continue the flow.

我不是C#的专家。

非常感谢你提前任何支持!!!

THANK YOU VERY MUCH IN ADVANCE FOR ANY SUPPORT!!!

这是我的编码:

  public void Main()

        {

            // TODO:在这里添加你的代码

            int xvar = 3;

            var result = MessageBox.Show(" Generate Template?"," CONFIRM",zh)
                          MessageBoxButtons.YesNo,

                          MessageBoxIcon.Question);







            if(result == DialogResult.Yes)

            {

                xvar = 1;

            }¥b $ b           否则if(结果== DialogResult.No)

            {

                xvar = 0;

            }¥b $ b            MessageBox.Show(xvar.ToString());

 public void Main()
        {
            // TODO: Add your code here
            int xvar=3;
            var result = MessageBox.Show("Generate Template?", "CONFIRM",
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Question);



            if (result == DialogResult.Yes)
            {
                xvar = 1;
            }
            else if (result == DialogResult.No)
            {
               xvar = 0;
            }
            MessageBox.Show(xvar.ToString());

            // V_door是我的包中定义的变量。我需要将值从xvar传递给V_door

           // V_door is the variable defined in my package. I need to pass the value from xvar to V_door

            //这是我试图使用的:

           // It is what I was trying to use:

            Dts.Variables [" User :: V_door"]。Value.Equals(xvar);

            Dts.ExecutionValue = xvar;

            Dts.Variables["User::V_door"].Value.Equals(xvar);
            Dts.ExecutionValue = xvar;

            Dts.TaskResult =(int)ScriptResults.Success;



        }

            Dts.TaskResult = (int)ScriptResults.Success;

        }

推荐答案

Dts.Variables [" User :: V_door"]。Value = xvar;
Dts.Variables["User::V_door"].Value = xvar;


这篇关于如何将脚本任务(c#)中的变量值传递给包中​​的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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