In BIDS (Microsoft Business Intelligence Development Studio), how can you initialize a variable via a package configuration? We have a script task in a package which uses user variables. The user variables are hardcoded. We'd like to make the script task configurable. We have a SQL Server package configuration table which stores package configurations.
Would we want to initialize the variable in the script task code or can it be done in the variables table?
What is the syntax if the variable is VariableName and the configuration name for the package configuration is "Configuration Name"?
Also, does it make sense to initialize the variable with the package configuration value or would it be better to use the package configuration directly?
These are the current package configurations:
This is from the Variables window:
This is the code from the script task:
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
Thank You!
michaelc35