2016-03-29 6 views
0

BIDS(Microsoft Business Intelligence Development Studio)では、パッケージ構成を使用して変数を初期化する方法はありますか?ユーザー変数を使用するパッケージ内にスクリプトタスクがあります。ユーザー変数はハードコードされています。スクリプトタスクを構成可能にしたいと考えています。パッケージ構成を格納するSQL Serverパッケージ構成テーブルがあります。パッケージ構成でSSIS変数を初期化する

スクリプトタスクコードで変数を初期化したいのですが、それとも変数テーブルで行うことができますか?

変数がVariableNameで、パッケージ構成の構成名が「構成名」の場合の構文は何ですか?

また、パッケージの設定値で変数を初期化することは意味がありますか、パッケージ構成を直接使用する方がよいでしょうか?

これらは、現在のパッケージ構成されている:

enter image description here

これは、変数ウィンドウから次のとおりです。

enter image description here

これは、スクリプトタスクからのコードです:

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

答えて

1

むしろ間で変数を使用するよりも、直接ターゲットプロパティを設定するには、一般的に明確です。

しかし、スクリプトタスク内の値を参照しているので、から変数にアクセスするのではなく、そのスクリプトタスクが設定値に直接アクセスできる方法はわかりません。 (私が知りませんが、誰かがそれを投稿した場合に読むことに興味があるようなコードの方法があるかもしれません)。

設定から変数の値を設定するための構文は次のとおりです。

\ Package.Variables [ユーザー::変数名] .propertiesファイル[値]

(明らかに、あなたの変数の名前と変数名を置き換えます)。この値は、構成された値をパッケージに「ポーズ」する場所を指定します。私の設定テーブル(SSIS2008を使用して)では、PackagePathカラムに入ります。変数に割り当てる値は、ConfiguredValue列になります。

関連する問題