如何提示SSIS包的输入?

时间:2022-09-20 10:28:17

I want to be able to have a sql query in my DTSX package and I want to be able to have some sort of prompt to update the value of a null column. See what I have below:

我希望能够在我的DTSX包中有一个SQL查询,我希望能够有一些提示来更新空列的值。看看我下面的内容:

UPDATE  SF1411
SET     [QuoteNumber]   = '123456'
    ,   [ItemNumber]    = '123654-100'
    ,   [DeleteItem]    = 'NO'
WHERE   [QuoteNumber]   = '0'

I want to be able to be prompted for the QuoteNumber and ItemNumber, then have the script update as needed. Is this possible and if so how can I do it?

我希望能够提示您输入QuoteNumber和ItemNumber,然后根据需要更新脚本。这是可能的,如果可以的话我该怎么做?

2 个解决方案

#1


9  

This can be acheived as below: This will be in your intial script component.

这可以实现如下:这将在您的初始脚本组件中。

    System.Windows.Forms.Form frm = new Form();
    TextBox txt = new TextBox();
    Button inputset = new Button();

    public void Main()
    {
        inputset.Text = "Set Variable Value";
        inputset.Width = 200;
        inputset.Height = 100;
        inputset.Click += new EventHandler(inputset_Click);
        txt.Name = "Input";
        frm.Controls.Add(txt);
        frm.Controls.Add(inputset);
        frm.ShowDialog();
        MessageBox.Show(Dts.Variables["Value1"].Value.ToString());


        Dts.TaskResult = (int)ScriptResults.Success;
    }

    void inputset_Click(object sender, EventArgs e)
    {
        Dts.Variables["Value1"].Value = Convert.ToInt32(txt.Text);
        frm.Close();
    }

This should be the initial component in your package to set the variable value or construct you SQL Command.

这应该是包中的初始组件,用于设置变量值或构造SQL命令。

#2


2  

In general, an SSIS package is not used interactively. Your cleanest solution is a custom solution that gets the input from the user, and then launches the SSIS package.

通常,不会以交互方式使用SSIS包。您最干净的解决方案是一个自定义解决方案,它从用户那里获得输入,然后启动SSIS包。

A simpler alternative is using Package Configurations. You can store the user input in an external location (XML file, SQL Server database, and others) and the SSIS package will load the value at run time.

更简单的替代方法是使用包配置。您可以将用户输入存储在外部位置(XML文件,SQL Server数据库等),SSIS包将在运行时加载该值。

#1


9  

This can be acheived as below: This will be in your intial script component.

这可以实现如下:这将在您的初始脚本组件中。

    System.Windows.Forms.Form frm = new Form();
    TextBox txt = new TextBox();
    Button inputset = new Button();

    public void Main()
    {
        inputset.Text = "Set Variable Value";
        inputset.Width = 200;
        inputset.Height = 100;
        inputset.Click += new EventHandler(inputset_Click);
        txt.Name = "Input";
        frm.Controls.Add(txt);
        frm.Controls.Add(inputset);
        frm.ShowDialog();
        MessageBox.Show(Dts.Variables["Value1"].Value.ToString());


        Dts.TaskResult = (int)ScriptResults.Success;
    }

    void inputset_Click(object sender, EventArgs e)
    {
        Dts.Variables["Value1"].Value = Convert.ToInt32(txt.Text);
        frm.Close();
    }

This should be the initial component in your package to set the variable value or construct you SQL Command.

这应该是包中的初始组件,用于设置变量值或构造SQL命令。

#2


2  

In general, an SSIS package is not used interactively. Your cleanest solution is a custom solution that gets the input from the user, and then launches the SSIS package.

通常,不会以交互方式使用SSIS包。您最干净的解决方案是一个自定义解决方案,它从用户那里获得输入,然后启动SSIS包。

A simpler alternative is using Package Configurations. You can store the user input in an external location (XML file, SQL Server database, and others) and the SSIS package will load the value at run time.

更简单的替代方法是使用包配置。您可以将用户输入存储在外部位置(XML文件,SQL Server数据库等),SSIS包将在运行时加载该值。