SSIS: Setting a Custom Property in a Data Flow Component
Posted by dariosantarelli on July 26, 2007
If you want to set a Custom Property (like OpenRowSet) of a Data Flow Component (like an OLE DB Source) in a Data Flow Task you can use the code below:
using Microsoft.SqlServer.Dts.Runtime;
// Classes and interfaces to create Data Flow Components and automate Data Flow Tasks
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
…
TaskHost MyTaskHost = (TaskHost)package.Executables[0]; // Pay attention to the ordinal number 😉
// MainPipe: wrapper to configure a Data Flow Task programmatically
MainPipe dataFlowTask = MyTaskHost.InnerObject as MainPipe;
// Each Data Flow Task component is represented by a ComponentMetadata
IDTSComponentMetaData90 MyComponentMetadata = dataFlowTask.ComponentMetaDataCollection[“MyComponentName”];
IDTSCustomProperty90 CustomProperty = MyComponentMetadata.CustomPropertyCollection[“OpenRowset”];
CustomProperty.Value = “MyValue”;
…
cool said
thank you very much!:)
Josh said
nice example mate.. perfect 😉
Padmaraj said
I’m getting error while setting “OpenRowset” for “DTSTransform.SCD” using IDTSCustomProperty100