Vb.net 使用包配置初始化SSIS变量

Vb.net 使用包配置初始化SSIS变量,vb.net,ssis,visual-studio-2005,bids,Vb.net,Ssis,Visual Studio 2005,Bids,在BIDS(Microsoft Business Intelligence Development Studio)中,如何通过包配置初始化变量?我们在使用用户变量的包中有一个脚本任务。用户变量是硬编码的。我们希望使脚本任务可配置。我们有一个存储包配置的SQLServer包配置表 我们是想在脚本任务代码中初始化变量,还是可以在变量表中初始化 如果变量是VariableName,包配置的配置名称是“配置名称”,那么语法是什么 另外,用包配置值初始化变量有意义吗?还是直接使用包配置更好 以下是当前的软

在BIDS(Microsoft Business Intelligence Development Studio)中,如何通过包配置初始化变量?我们在使用用户变量的包中有一个脚本任务。用户变量是硬编码的。我们希望使脚本任务可配置。我们有一个存储包配置的SQLServer包配置表

我们是想在脚本任务代码中初始化变量,还是可以在变量表中初始化

如果变量是VariableName,包配置的配置名称是“配置名称”,那么语法是什么

另外,用包配置值初始化变量有意义吗?还是直接使用包配置更好

以下是当前的软件包配置:

这是从变量窗口:

这是脚本任务中的代码:

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO

Public Class ScriptMain

    ' The execution engine calls this method when the task executes.
    ' To access the object model, use the Dts object. Connections, variables, events,
    ' and logging features are available as static members of the Dts class.
    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    ' 
    ' To open Code and Text Editor Help, press F1.
    ' To open Object Browser, press Ctrl+Alt+J.

    Public Sub Main()
        '
        ' Add your code here
        '
        Dim fileName As String

        fileName = CStr(Dts.Variables("User::TrialBalanceReportDirectory").Value) + _
                CStr(Dts.Variables("User::Slash").Value) + _
                CStr(Dts.Variables("User::TrialBalanceReportFile").Value)

        'MsgBox(fileName)

        Dts.Variables("TrialBalanceReportExists").Value = File.Exists(fileName)
        Dts.TaskResult = Dts.Results.Success
    End Sub

End Class
谢谢大家!


michaelc35

直接配置目标属性通常更清晰,而不是在两者之间使用变量

但是,由于您引用的是脚本任务中的值,因此我看不出该脚本任务可以直接访问配置值,而不是通过变量访问它们。(在代码中可能有一种方法,我不知道,但如果有人发布它,我会有兴趣阅读)

从配置中设置变量值的语法为:

\Package.Variables[User::VariableName].Properties[Value]

(显然,用变量的名称替换VariableName)。此值指定应将配置的值“插入”到包中的位置。在我的配置表(使用SSI2008)中,它位于PackagePath列中。然后,要分配给变量的值进入ConfiguredValue列