Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
626 views
in Technique[技术] by (71.8m points)

sql - How do I prompt for input from an SSIS package?

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:

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...