【发布时间】:2016-03-29 19:39:27
【问题描述】:
在 BIDS (Microsoft Business Intelligence Development Studio) 中,如何通过包配置初始化变量?我们在使用用户变量的包中有一个脚本任务。用户变量是硬编码的。我们想让脚本任务可配置。我们有一个存储包配置的 SQL Server 包配置表。
我们是要在脚本任务代码中初始化变量还是可以在变量表中完成?
如果变量是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
【问题讨论】:
标签: vb.net ssis visual-studio-2005 bids