TaskHostオブジェクトを使用してプロパティを設定していることがわかります。プロパティを動的に設定する場合は、TaskHostを使用することをお勧めします。基本的な制御フロータスクを直接使用してプロパティを設定することもできますが、場合によってはそれが望ましい場合もあります。
ここでExecuteSQLTaskオブジェクトを直接使用してパラメータバインディングを追加できます。 ExecuteSqlTaskのParameterBindingsプロパティでAddメソッドを呼び出すだけです。
ExecuteSqlTaskオブジェクトを使用するには、Microsoft.SqlServer.SQLTask.dllにアセンブリ参照を追加する必要があります。
TaskHostのInnerObjectをExecuteSqlTaskにキャストし、ExecuteSqlTaskのParameterBindingsプロパティでAddメソッドを呼び出します。結果バインディングも追加するために同じパターンが使用されます。
// cast the TaskHost's InnerObject as ExecuteSqlTask
// add a reference to the Microsoft.SqlServer.SQLTask.dll to use ExecuteSqlTask
ExecuteSQLTask sqlTask = TaskHost.InnerObject as ExecuteSQLTask;
// call the Add method on ParameterBindings property of sqlTask.
//This will return a IDTSParameterBinding object
IDTSParameterBinding parameterBinding = sqlTask.ParameterBindings.Add();
// using the IDTSParameterBinding object that is returned from the Add call, set the various properties
parameterBinding.ParameterName = "ParamName";
parameterBinding.ParameterDirection = ParameterDirections.Input;
// set more properties on parameterBinding as needed ......
ありがとうございました – Tempest