【问题标题】:SSIS Script task get all the variable names and valuesSSIS 脚本任务获取所有变量名称和值
【发布时间】:2012-07-25 13:54:02
【问题描述】:

我需要解析我的 ssis 包中的所有用户变量。到目前为止,我能够获取包中所有变量的名称和值。我需要获取名称和值并将它们转储到表中。截至目前,我可以通过消息框显示名称和值,但我似乎无法弄清楚,如何在脚本任务中将这些值转储到表中。任何帮助将不胜感激。

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
//using System;
////using Microsoft.SqlServer.Dts.Runtime;
namespace ST_81ec2398155247148a7dad513f3be99d.csproj
{
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {

        #region VSTA generated code
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion

    public void Main()
    {


        Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
        // Load a sample package that contains a variable that sets the file name.
        Package pkg = app.LoadPackage(
          @"C:\PackagePath\" +
          @"Template0719.dtsx",
          null);
        Variables pkgVars = pkg.Variables;
        foreach (Variable pkgVar in pkgVars)
        {

            MessageBox.Show(pkgVar.Name);
            MessageBox.Show(pkgVar.Value.ToString());
        }
        Console.Read();
    }
    }

    }

【问题讨论】:

标签: c# sql-server-2008 ssis custom-component


【解决方案1】:

既然您知道如何获取变量列表,您就可以创建一个数据源脚本组件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-13
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多