by robotix1986
16. July 2009 16:02
Well this entry is all code.. no explanations... you figure it out yourselves
Microsoft.SqlServer.Dts.Runtime.
Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
Executable executable = package.Executables.Add("STOCK:PipelineTask");
Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = executable as Microsoft.SqlServer.Dts.Runtime.TaskHost;
MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;
// Add a flat file destination component to the data flow task
IDTSComponentMetaData100 destinationComponent = dataFlowTask.ComponentMetaDataCollection.New();
destinationComponent.Name = "FlatFileDestination";
destinationComponent.ComponentClassID = "DTSAdapter.FlatFileDestination";
// Get the design time instance of the flat file destination component.
CManagedComponentWrapper destinationInstance = destinationComponent.Instantiate();
// Initialize the flat file destination component
destinationInstance.ProvideComponentProperties();
// Configure the flat file destination component to use the Flat File connection manager
destinationComponent.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(destinationConnection);
destinationComponent.RuntimeConnectionCollection[0].ConnectionManagerID = destinationConnection.ID;
// Configure the custom properties of the Flat File destination component
destinationInstance.SetComponentProperty("Header", "");
destinationInstance.SetComponentProperty("Overwrite", true);
// Reinitialize the metadata.
destinationInstance.AcquireConnections(null);
destinationInstance.ReinitializeMetaData();
destinationInstance.ReleaseConnections();
// ADD OTHER TASKS HERE
Hope this helps.
Regards,
AlD
by robotix1986
22. June 2009 20:43
Hi g33ks,
The SSIS object model gives us the flexibility of dynamically creating SSIS packages and running them. One major boon with this is that instead of doing column mapping of DFTs at design time, we can do this at runtime and have the mapping information in the metadata.
Today instead of posting some sample code for some basic stuff in creating SSIS packages, I thought that it would make more sense to just post some links which have sample code for various kinds of basic tasks in SSIS. So here goes.
Adding connections - http://msdn.microsoft.com/en-us/library/ms136093.aspx
Variables - http://msdn.microsoft.com/en-us/library/ms136082.aspx
Adding a Data Flow Task - http://msdn.microsoft.com/en-us/library/ms135997.aspx
Adding Data Flow Components - http://msdn.microsoft.com/en-us/library/ms135932.aspx
Connecting Data Flow Components - http://msdn.microsoft.com/en-us/library/ms136086.aspx
ADO.NET Source - http://blogs.msdn.com/mattm/archive/2008/12/30/api-sample-ado-net-source.aspx
OLEDB Source & Destination - http://blogs.msdn.com/mattm/archive/2008/12/30/api-sample-oledb-source-and-oledb-destination.aspx
Saving a Package - http://msdn.microsoft.com/en-us/library/ms403347.aspx
More elaborate samples to come soon. Till then, Adeus.
Regards,
AlD